Skip to main content

No project description provided

Project description

pathlibutil

PyPI - Python Version PyPI PyPI - Downloads PyPI - License GitHub Workflow Test)


pathlibutil.Path inherits from pathlib.Path with some useful built-in python functions.

  • Path().hexdigest() to calculate and Path().verify() for verification of hexdigest from a file
  • Path.default_hash to configurate default hash algorithm for Path class (default: 'md5')
  • Path().size() to get size in bytes of a file or directory
  • Path().read_lines() to yield over all lines from a file until EOF
  • contextmanager to change current working directory with with 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

  1. Read file line by line to stdout

    Path().read_lines()

  2. Write calculated hash to file

    Path().hexdigest()

  3. Read hashes from file for verification

    Path().verify() and contextmanager

Project details


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)

Uploaded Source

Built Distribution

pathlibutil-0.1.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

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

Hashes for pathlibutil-0.1.0.tar.gz
Algorithm Hash digest
SHA256 41c85d60c14769b266b07408cc576fac74f21fa790ad9f064d376ce0b169ab04
MD5 dba5e838d01c1b95ef1018f39c6a9831
BLAKE2b-256 1971ae962e6b6980f8db7d9ec7860907710e861914ccbc514ede69586f16570c

See more details on using hashes here.

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

Hashes for pathlibutil-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0413ad63054433c7b27592a32d9c4c7ec4de05627e03fc30ca03dca829151513
MD5 0120d45ce7c9e5392ad760e704ff1af8
BLAKE2b-256 2a8a891d54e09912fb2ea13187599aa736da64bfdb647566713c3b4c7b0d9a08

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page