No project description provided
Project description
pathlibutil
pathlibutil.Path
inherits from pathlib.Path
with some useful built-in python functions.
Path().hexdigest()
to calculate andPath().verify()
for verification of hexdigest from a filePath.default_hash
to configurate default hash algorithm forPath
class (default: 'md5')Path().size()
to get size in bytes of a file or directoryPath().read_lines()
to yield over all lines from a file until EOFcontextmanager
to change current working directory withwith
statement
Installation
pip install pathlibutil
Usage
from pathlibutil import Path
readme = Path('README.md')
print(f'File size: {readme.size()} Bytes')
print(f'File sha1: {readme.hexdigest("sha1")}')
print('-- File content --')
for line in readme.read_lines(encoding='utf-8'):
print(line, end='')
print('-- EOF --')
with readme.parent as cwd:
print(f'Current working directory: {cwd}')
# Change default hash algorithm from md5 to sha1
Path.default_hash = 'sha1'
print(f'File verification: {readme.verify("add3f48fded5e0829a8e3e025e44c2891542c58e")}')
Examples
- Read file line by line to stdout
Path().read_lines()
- Write calculated hash to file
Path().hexdigest()
- Read hashes from file for verification
Path().verify()
andcontextmanager
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
pathlibutil-0.1.0.tar.gz
(3.7 kB
view details)
Built Distribution
File details
Details for the file pathlibutil-0.1.0.tar.gz
.
File metadata
- Download URL: pathlibutil-0.1.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.6 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41c85d60c14769b266b07408cc576fac74f21fa790ad9f064d376ce0b169ab04 |
|
MD5 | dba5e838d01c1b95ef1018f39c6a9831 |
|
BLAKE2b-256 | 1971ae962e6b6980f8db7d9ec7860907710e861914ccbc514ede69586f16570c |
File details
Details for the file pathlibutil-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: pathlibutil-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.6 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0413ad63054433c7b27592a32d9c4c7ec4de05627e03fc30ca03dca829151513 |
|
MD5 | 0120d45ce7c9e5392ad760e704ff1af8 |
|
BLAKE2b-256 | 2a8a891d54e09912fb2ea13187599aa736da64bfdb647566713c3b4c7b0d9a08 |