Extends the functionalities of Pythion Pathlib
Project description
Pathlib Extensions
Add convenience methods to Python Pathlib via monkey patching.
Installation
Pathlibext is available in PyPI. To Install it use pip
:
pip install pathlibext
Usage
Just import pathlibext once and Path object will be extended with a series of convenience methods:
from pathlib import Path
import pathlibext # pylint: disable=unused-import
if __name__ == '__main__':
tmp = Path.tmpdir() # from pathlibext
files = [
tmp / "1" / "a.txt",
tmp / "1" / "b.txt",
tmp / "2" / "a.txt",
tmp / "2" / "b.txt",
]
for f in files:
f.parent.mkdir(exist_ok=True)
f.touch()
for d in tmp.find(type_="d", name="2"): # from pathlibext
print(f"removing {d}...")
d.rmtree() # from pathlibext
tmp.rmtree()
List of added methods
- Unix-like find:
Path(".").find(type_f, name="*.py", maxdepth=4)
- File name match: Path("/tmp/Something.txt).match("S*.txt)
- File name matchcase: Path("/tmp/Something.txt).matchcase("s*.txt)
- Remove non-empty directory tree: Path("/tmp/something/").rmtree()
- Copy: Path("tmp/something.txt).copy("~/tmp")
- Copy preserve metadata: Path("tmp/something.txt).copy_preserve_metadata("~/tmp")
- Move: Path("tmp/something.txt).move("~/tmp")
- File size: Path("tmp/something.txt).size()
- File access time: Path("tmp/something.txt).access_time()
- File modification time: Path("tmp/something.txt).modification_time()
- File creation time (Windows only): Path("tmp/something.txt).creation_time()
- File metadata change time (Posix only): Path("tmp/something.txt).metadatachange_time()
- System temporary directory as Path: Path.systmpdir()
- Create temporary directory as Path in existing directory: Path("tmp").tmpdir_in()
- Create temporary directory as Path: Path().tmpdir()
- Current file path: Path.current_file_path()
- Current file directory: Path.current_file_dir()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for pathlibext-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2eb9181d386465e6aab8b57735229f58d1e55a0f4701adc7bedb44846a74086 |
|
MD5 | 594833aecd79b6a811e86d27d909b73e |
|
BLAKE2b-256 | 3230d3eecf643863c55a10f97a454a55d3b2c68f4ebfc254227c4138f3ce7ca9 |