Skip to main content

An object-oriented path interface to archives, images, remote filesystems, etc

Project description

Latest version released on PyPi Documentation

Pathlab provides an object-oriented path interface to archives, images, remote filesystems, etc. It is built upon pathlib and includes built-in support for:

  • tar archives

  • zip archives

  • iso disc images (inc Rock Ridge; exc Joliet and UDF)

  • JFrog Artifactory (via requests)

You can also define your own Path subclass with its own accessor.

Installation

Requires Python 3.6+. Use pip:

pip install --user pathlab

Usage

These usage examples are adapted from the pathlib documentation.

Getting a path type:

>>> from pathlab import TarAccessor
>>> TarPath = TarAccessor('project.tgz').TarPath

Listing subdirectories:

>>> root = TarPath('/')
>>> [x for x in root.iterdir() if x.is_dir()]
[TarAccessor('project.tgz').TarPath('/docs')
 TarAccessor('project.tgz').TarPath('/etc'),
 TarAccessor('project.tgz').TarPath('/project')]

Listing Python source files in this directory tree:

>>> list(root.glob('**/*.py'))
[TarAccessor('project.tgz').TarPath('/setup.py'),
 TarAccessor('project.tgz').TarPath('/docs/conf.py'),
 TarAccessor('project.tgz').TarPath('/project/__init__.py')]

Navigating inside a directory tree:

>>> p = TarPath('/etc')
>>> q = p / 'init.d' / 'reboot'
>>> q
TarAccessor('project.tgz').TarPath('/etc/init.d/reboot')
>>> q.resolve()
TarAccessor('project.tgz').TarPath('/etc/rc.d/init.d/halt')

Querying path properties:

>>> q.exists()
True
>>> q.is_dir()
False

Opening a file:

>>> with q.open() as f: f.readline()
...
'#!/bin/bash\n'

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

pathlab-0.2.tar.gz (12.5 kB view details)

Uploaded Source

File details

Details for the file pathlab-0.2.tar.gz.

File metadata

  • Download URL: pathlab-0.2.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.9.1 pkginfo/1.4.1 requests/2.18.4 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/2.7.12

File hashes

Hashes for pathlab-0.2.tar.gz
Algorithm Hash digest
SHA256 e089925abd330ce1fffa1d1683a1e70b2f03a8dd71a4ad83380cd29838142a69
MD5 b79f672b96f61a56f300b7ec2c7dde0b
BLAKE2b-256 9fe6645a3ba346d332187f3573abff39f8bf47cf5591fcd357edc42dac12a8df

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