Skip to main content

a supercharged implementation of pathlib.Path()

Project description

In short

This libray propose to extend the capabilities of pathlib. The Path class provided here is a sub-class of the original pathlib.Path class.

It especially enable an easy interaction with widespread file formats like json, pickle or tsv files, plain or compressed.

Options are mostly not setable, this package was meant to fit my needs, not all :D.

from cc_pathlib import Path

In detail

Path.make_dirs(self, umask='shared') is an equivalent of Path.mkdir(parents=True, exists_ok=True), with the added possibility to set a umask to each directory created in-between. Especially, the default value is 'shared' for a mask value of 0o2770 (which means: available for read and write access to user and group but not others, and gid set such as each new file or directory created subsequently keep this properties).

Path.make_parents(self, umask='shared') same as Path.make_dirs(self, umask='shared') but works on files, it create the whole directory structure above it. It does not create the file though.

Path.delete(self, content_only=False) delete recursively if the Path is a directory. If content_only=True it keeps the root directory once emptied.

Path.or_archive return the name of a corresponding archive if it exists. Looking at the following extensions, in this order, .br, .lz, .gz. This function is meant to work on files, not on complex archives like .tar files.

Path.load(self, encoding='utf-8') is an auto-loader. The type of file is guessed from the extension

The auto-loader

The auto-loader works in two steps :

  1. if the file is compressed with one of the following extensions, it is first unzipped :
    • .gz for gzip
    • .br for brotli
    • .lz for lzip
  2. if the file match one of the following filter, the content is properly parsed, and only the resulting object is returned:
    • .pickle for a pickled file
    • .json for a json data structure
    • .tsv for a tab separated value type of file, returned as a list() of list() of str(). The complete spec of a .tsv file is described below

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

cc-pathlib-0.0.10.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cc_pathlib-0.0.10-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file cc-pathlib-0.0.10.tar.gz.

File metadata

  • Download URL: cc-pathlib-0.0.10.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.5

File hashes

Hashes for cc-pathlib-0.0.10.tar.gz
Algorithm Hash digest
SHA256 a1b4f6b5d4251184cc28245b0b0d9c743273f4eb299872e3449cf3ead9c20bf9
MD5 d025559272e00db5388cc03417dffb95
BLAKE2b-256 baf00703860a9bd39cc864c5c83898448db0a47896708d755adee45c92587d5f

See more details on using hashes here.

File details

Details for the file cc_pathlib-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: cc_pathlib-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.5

File hashes

Hashes for cc_pathlib-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 54a5dd8d1173d3870c71892b393017d8f85e3a27a9b9ec93cb60e73e10b0f51d
MD5 658bc648e09e2378e823f09a71c90760
BLAKE2b-256 d033f20e99c4711c7f3701bb528953dfba49b07196613c54b9afb43a5d6c44a9

See more details on using hashes here.

Supported by

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