pathio
Path collection class for checking paths for input and output files/directories.
- Initializing a collection (and later path additions) runs the suite of checks:
- Duplication, existence (inputs), ... TODO add all checks
- Printing/logging the collection provides a summary of the paths.
- Paths are converted to
pathlib.Pathobjects and missing directories can be created. - Can create missing output directories.
Installation
Install from PyPI:
pip install pathio
Install from GitHub:
python -m pip install git+https://github.com/ludvigolsen/pathio
Main class/functions
| Class/Function | Description |
|---|---|
IOPaths |
Collection of paths with built-in checks. |
mk_dir |
Wrapper for creating directory if it doesn't exist. |
rm_dir |
Wrapper for removing directory with relevant options. |
Examples
Initialize the collection of path collections. Often the paths come from input arguments (like via argparse).
Additional paths can be added later with set_path() or set_paths().
# Create path collection
paths = IOPaths(
in_files={
"in_file": "../dir1/dir2/john.csv",
"stream_in": "-"
},
in_dirs={
"in_dir": "../dir1/dir2/",
},
out_files={
"out_file": "../dir1/dir2/output/no_john.csv"
},
out_dirs={
"out_path": "../dir1/dir2/output/"
}
)
Add additional path. Reruns checks to ensure consistency.
paths.set_path(
name="in_file_2",
path="../dir1/dir2/dennis.csv",
collection="in_files"
)
Or set multiple at a time to avoid rerunning checks unnecessarily:
paths.set_paths(
paths={
"out_file_2": "../dir1/dir2/output/no_dennis.csv"
"out_file_3": "../dir1/dir2/output/readme.txt"
},
collection="out_files"
)
Create the output directories that do not exist:
paths.mk_output_dirs(collection="out_dirs")
Get a path:
paths["in_file"] # or
paths.get_path(name="in_file", as_str=False, raise_on_fail=True)
Remove file from disk:
paths.rm_file(name="in_file")
Update collection with another IOPaths collection.
The sub collections are simple dicts, why this is just dict.update()
on each sub collection.
paths.update(other=other_paths)
Find the combinations of keys and paths in the collections of this object that are not in the collections of another object:
paths.difference(other=other_paths)
Metadata
Release files for pathio 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pathio-0.1.0.tar.gz | 13.3 kB | Without provenance | Details for pathio-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pathio-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for pathio-0.1.0-py3-none-any.whl |
Total release size: 27.8 kB
Release files / pathio-0.1.0.tar.gz
| Download URL | pathio-0.1.0.tar.gz |
|---|---|
| Size | 13.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6d07c7e6b90e6dfc9d6fb5acb60680e298a037c08d28996aa01c3784337a34db
|
|
BLAKE2b-256 checksum How to use checksums |
5c73b02b74623a2f30370cb1272d1d1e4f6890d05e8f7a79e81260cf605d11ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.1 CPython/3.9.6 Darwin/23.6.0
|
Release files / pathio-0.1.0-py3-none-any.whl
| Download URL | pathio-0.1.0-py3-none-any.whl |
|---|---|
| Size | 14.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bad15816d2b929d10fb2452f7f3bbcbe35818108d886fc8069375b090a1ef7c5
|
|
BLAKE2b-256 checksum How to use checksums |
ae8e6186f4f1725f731a268f11b982f3a849f4b5b4eaed8a5a11acdb328170b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.1 CPython/3.9.6 Darwin/23.6.0
|
Security for pathio 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.