GithubHelp home page GithubHelp logo

pdiegel / fileutils Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 118 KB

A Python module providing classes and methods for working with files, including retrieving file information, handling Red Stake files, and relocating files to destination directories.

License: MIT License

Python 100.00%
file-handling information-retrieval relocation file-manager file-utilities python python3

fileutils's Introduction

File Baseclass

This Python module provides the File class, which represents a generic Windows file. It includes methods for retrieving information about the file, such as its type, name, size, and creation and modification dates.

Usage

To use this module, simply create an instance of the File class, passing in the path to the file as a string argument:

from file import File file = File("C:\\path\\to\\file.txt")

You can then use the following methods and properties to retrieve information about the file:

file_type

Returns the file type of the file.

print(file.file_type) # "txt"

file_name

Returns the file name of the file.

print(file.file_name) # "file"

exists

Returns True if the file exists, False otherwise.

print(file.exists) # True

file_size

Returns the file size in bytes. Raises a FileNotFoundError if the file does not exist.

print(file.file_size) # 12345

creation_date

Returns the creation date of the file as a string. Raises a FileNotFoundError if the file does not exist.

print(file.creation_date) # "05/05/2023 10:30:15"

modification_date

Returns the modification date of the file as a string. Raises a FileNotFoundError if the file does not exist.

print(file.modification_date) # "05/05/2023 10:30:15"

repr()

Returns a string representation of the file.

print(repr(file)) # "File(C:\\path\\to\\file.txt)"

str()

Returns a string representation of the file.

print(str(file)) # "C:\\path\\to\\file.txt"

len()

Returns the file size in bytes. Raises a FileNotFoundError if the file does not exist.

print(len(file)) # 12345

RedStakeFile Class

This Python module provides the RedStakeFile class, which represents a Red Stake Surveyors file. It is a subclass of the File class and provides additional methods and properties for working with Red Stake files. To use this module, simply create an instance of the RedStakeFile class, passing in the path to the file as a string argument:

from redstakefile import RedStakeFile file = RedStakeFile("C:\\path\\to\\file.dwg")

You can then use the following methods and properties to retrieve information about the file:

file_number

Returns the 8-digit file number of the Red Stake file. Reformats the number if necessary.

print(file.file_number) # "23040186"

file_year

Returns the year of the Red Stake file.

print(file.file_year) # "23"

file_month

Returns the month of the Red Stake file.

print(file.file_month) # "04"

file_destination_dir

Returns the destination directory of the Red Stake file. This is the directory to which the file should be moved based on its file type and file number.

print(file.file_destination_dir) # "\\server\dwg\23dwg\04"

move_files()

This function relocates all Red Stake files in the specified source directory to their destination directories on the server.

from redstakefile import relocate_files relocate_files("C:\\path\\to\\source\\directory")

Requirements

This module requires Python 3.x and the os and shutil modules, which are included in the Python standard library. It also requires the File class from the file module in the same repository.

License

This module is released under the MIT license. See LICENSE for more details.

fileutils's People

Contributors

pdiegel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.