Top-level package for disambigufile.
Project description
Class with file-like interface to a file found in provided search path
Free software: MIT license
Documentation: https://disambigufile.readthedocs.io.
Features
Search a path for a file that matches a pattern
Search a path for a file inside directories that match a pattern
Basic file interface (DisFile(…).open(), with DisFile(…) as f: …)
Get path from config file (if optini module installed)
Examples
Simple usage:
from disambigufile import DisFile
path = '/bin:/usr/bin:/usr/local/bin'
try:
print(DisFile('^ls', path=path))
except Exception as e:
print(f"unable to disambiguate file; exception: {e}")
Using a with statement to open the disambiguated file:
from disambigufile import DisFile
path = 'path1:path2'
try:
with DisFile(r'^asdf', path=path) as f:
print(f.read())
except Exception as e:
print(f"unable to disambiguate file; exception: {e}")
With more specific exception handling:
from disambigufile import DisFile
import disambigufile
path = '/bin:/usr/bin:/usr/local/bin'
try:
print(DisFile('^ls', path=path))
except disambigufile.Error as e:
# will only catch module-specific exceptions
print(f"unable to disambiguate file; exception: {e}")
Match a file inside of a matched directory:
from disambigufile import DisFile
# search for unique file matching ~/Datasets/*2019-08-19*/data*
path='~/Datasets'
try:
hit = DisFile(
pattern='2019-08-19',
path=path,
subpattern='^data',
)
print(hit)
except disambigufile.Error as e:
print(f"unable to disambiguate file; exception: {e}")
Credits
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
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
Built Distribution
Hashes for disambigufile-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6861455492171c86946b6a7e29c3ec1159e10d9a0c013a51c364b6903cd328ff |
|
MD5 | d2693d9847ab1bc108f7ff93b3823a51 |
|
BLAKE2b-256 | f634df429fc1b5c2cf13299686744d81e02edbfd0194c032f593b5513bfb210e |