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 hashes)
Built Distribution
Close
Hashes for pathlibutil-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0413ad63054433c7b27592a32d9c4c7ec4de05627e03fc30ca03dca829151513 |
|
MD5 | 0120d45ce7c9e5392ad760e704ff1af8 |
|
BLAKE2b-256 | 2a8a891d54e09912fb2ea13187599aa736da64bfdb647566713c3b4c7b0d9a08 |