A dead simple Python 3.x file helper
A dead simple file helper for Python 3.x.
pip install libfile
libfile provides basic utilities for file interaction and management.
Make sure you import the
File class from
libfile and instanciate it with a path.
from libfile import File test_file = File("test_file.txt")
Note that the
File class gives dates as a
datetime. If you wish to get the raw dates (as a unix timestamp), instanciate the class with
dates_as_datetime set to
.path = str -> The given path .abs_path = str -> The absolute path of .path .readable = bool -> Whether or not the file is readable .data = str -> The contents of the file .lines = list -> A list of the lines in the file .line_count = int -> The length of .lines .is_empty = bool -> Whether or not the file is empty .size_in_bytes = int -> The size of the file, in bytes .size = str -> The size of the file, formatted .created = datetime/int -> When the file was created .last_modified = datetime/int -> When the file was last modified .last_accessed = datetime/int -> When the file was last accessed .full_name = str -> Full name of the file, excluding its path .name = str -> Name of the file, excluding its path and extension .extension = str -> File extension, excluding its path and name .dir_path = str -> Path of the file's directory .dir_name = str -> Name of the file's directory
Rename the file to
Copy the file to
location with an optional
Duplicate the file
amount times with an optional
test_file.duplicate(amount=3, splitter=" ") # <directory> | # - test_file.txt # - test_file 0.txt # - test_file 1.txt # - test_file 2.txt
Move the file to
location. This method is followed automatically.
Delete the file.
test_file.delete() # Poof!
Find all lines from the given
test_file.find("testing") # ["Stop testing me!"]
Empty the file.
test_file.empty() # NNNOOOoooooooₒₒₒₒₒₒₒ...
There are still a lot of things to be implemented. Feel free to contribute anything you think should be added!
Following is a very simple method in the
File class which calls for
os to change the directory to the given
It is available in most methods as an argument, and can be disabled.
We welcome all contributions. Before submitting a pull request, make sure your editor supports
pylint for Python linting,
autopep8 for Python formatting, and
editorconfig for general file quality assurance.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size libfile-0.0.1-py3-none-any.whl (5.4 kB)||File type Wheel||Python version py3||Upload date||Hashes View hashes|
|Filename, size libfile-0.0.1.tar.gz (4.5 kB)||File type Source||Python version None||Upload date||Hashes View hashes|