A small cross-platform file library in Python
Project description
PythonFileLibrary
A small cross-platform file library dedicated to reading and searching for specific files in Python. Features two classes:
FileReader.py
A line-by-line file reader with cursor manipulation.
Cached text file can be read through cursor manipulation, where the cursor can be moved up or down to return the current line. If the cursor is out of bounds, it will return either the first or last line of the file.
__init__(self, fileName : str, fileList : [str] = [])
- Choose to create a FileReader from a file via import or from a list.
GetFilename(self) -> str
- Returns the name of the file that is being read.
GetFileLength(self) -> int
- Returns the amount of lines counted by each newline escape character (\n
).
GetCursorPosition(self) -> int
- Gets the current line position being read by the cursor [0 - GetFileLength() - 1].
GetCurrentLine(self) -> str
- Gets the current line the cursor is on as a string.
ResetCursor(self)
- Resets the cursor position to be at the top of the file.
Read(self) -> str
- Yields the entire file starting from the current cursor position while allowing for cursor manipulation;
Detailed information is in source code.
__iter__(self) -> str
- Shorthand for Read(self).
MoveCursorTo(self, line: int)
- Moves the cursor to a specific line in the file [clamped between 0 - GetFileLength() - 1], regardless of it
currently being Read(self) or not.
MoveCursorUp(self, amount: int = 1)
- Moves the cursor up by a number of lines [clamped to 0], regardless of it
currently being Read(self) or not.
MoveCursorDown(self, amount: int = 1)
- Moves the cursor down by a number of lines [clamped to GetFileLength() - 1], regardless of it
currently being Read(self) or not.
ReachedEnd(self) -> bool
- Whether or not the cursor is currently at the last line of the file.
RecursiveScanner.py
Recursively scans a directory for files of a specific extension.
__init__(self, directory)
- Create a Recursive Scanner that scans in a certain directory.
Scan(self, whitelist: [str], maxDepth: int = 0) -> [str]
- Recursively scan for files in the given directory with a specific extension;
Detailed info in source code.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file PythonFileLibrary-1.0.1.tar.gz
.
File metadata
- Download URL: PythonFileLibrary-1.0.1.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9ad1c95c44779378ada45bf10ff087f961f15e8a7558545058c262cfcd94f91 |
|
MD5 | 720f6daef713d5c2f6b0c0959115bf8d |
|
BLAKE2b-256 | 1cc8346bee98f460ac8cd16b2f025e4d30c931f8ca3e1aedd0104316a47b5228 |
File details
Details for the file PythonFileLibrary-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: PythonFileLibrary-1.0.1-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 236f868c8fbd1ffbde6fbf3cc537647c5a52b73791ecd91fba6184fb1aa29cb6 |
|
MD5 | 74cdf1e3c1efdee059dfa90e12f8e2e8 |
|
BLAKE2b-256 | 61418d501cc66f9c6a4a8b8b32fac4f7ed1059b6419339a4b79b9eefc27bf366 |