An extended and more powerful pathlib.
Project description
Welcome to pathlib_mate Documentation
pathlib is an awesome library handling path in different OS. And it’s been added into standard library since Python3.4. pathlib_mate gives extensive methods and attributes, makes pathlib more powerful and user-friendly.
Features:
Convenient Attribute Accessor:
>>> p = Path("/Users/username/test.py").
>>> p.abspath
/Users/username/test.py
>>> p.basename
test.py
>>> p.fname
test
>>> p.ext
.py
>>> p.dirname
username
>>> p.dirpath
/Users/username
>>> p.size
1500
>>> p.size_in_text
1.46 KB
>>> p.create_datetime
datetime(2018, 1, 15, 8, 30, 15)
>>> p.md5
415f12f07a7e01486cc82856621e05bf
>>> p.sha256
d51512cb0ac71484c01c475409a73225d0149165024d7aac6d8e655eedf2c025
>>> p.sha512
7882fc375840cafa364eaf29dc424645b72fcdbe61fc3326c5afd98e70f696e4f390e0e3f159eac2cb60cedc0992ef7b5f8744a4481911e914a7c5b979e6de68
Powerful Path Search:
>>> p = Path("/Users/username/Documents")
>>> for path in p.select_file(recursive=True)
...
>>> for path in p.select_file(recursive=False)
...
>>> for path in p.select_dir(recursive=True)
...
>>> for image_file in p.select_by_ext([".jpg", ".png"])
...
>>> for big_file in p.select_by_size(min_size=1000000)
...
>>> for video_file in p.select_video():
...
# You can customize the filter anyway you want
>>> def py_filter(p): return ".py" == p.ext.lower()
>>> for py_file in p.select_file(py_filter):
...
Eazy to use File / Dir Operation:
>>> p = Path("/Users/username/Documents/Readme.txt")
# mutate
>>> p.change(new_ext=".md")
/Users/username/Documents/Readme.md
>>> p.change(new_fname="Tutorial")
/Users/username/Documents/Tutorial.txt
>>> p.change(new_basename="README.rst")
/Users/username/Documents/README.rst
>>> p.change(new_dirname="Downloads")
/Users/username/Downloads/Readme.txt
>>> p.change(new_dirpath="/User/username/Downloads)
/Users/username/Downloads/Readme.txt
>>> p.change(new_abspath="/Users/username/Downloads/Readme.txt")
/Users/username/Downloads/Readme.txt
# copy
>>> p.moveto(new_ext=".md", makedirs=True)
# cut
>>> p.copyto(new_ext=".md", makedirs=True)
# delte
>>> p.remove()
Powerful Production Tools:
>>> p = Path("/Users/username/Documents/Github/pathlib_mate-project")
>>> p.print_big_dir_and_big_file()
...
>>> p.file_stat()
{"file": 122, "dir": 41, "size": 619682}
# file statistics, include sub folder
>>> p.file_stat_for_all()
# make an zip archive for the directory, auto naming
>>> p.make_zip_archive()
# make an zip archive for the directory, auto naming
>>> p.backup()
Install
pathlib_mate is released on PyPI, so all you need is:
$ pip install pathlib_mate
To upgrade to latest version:
$ pip install --upgrade pathlib_mate
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
pathlib_mate-0.0.14.tar.gz
(142.8 kB
view details)
Built Distribution
File details
Details for the file pathlib_mate-0.0.14.tar.gz
.
File metadata
- Download URL: pathlib_mate-0.0.14.tar.gz
- Upload date:
- Size: 142.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/2.7.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae112d52959ef0437976259463e6c761f14c8add2c488351b8701e1715dfdef6 |
|
MD5 | 0fa8e3009ec0911ba9c4f33daef91606 |
|
BLAKE2b-256 | 2136129cf9d61be44a1bd18a7fb3def2098d73e1db5955f3ca05c148e73ab805 |
File details
Details for the file pathlib_mate-0.0.14-py2.py3-none-any.whl
.
File metadata
- Download URL: pathlib_mate-0.0.14-py2.py3-none-any.whl
- Upload date:
- Size: 195.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/2.7.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1534cfea8baed5ac2743eab2a698a6c72164799ffb3af61b9eeb6207334d35a2 |
|
MD5 | 6952e5e9c44c0a3073adf1b7ec7630c7 |
|
BLAKE2b-256 | c33cfb7e89f70eb905b8d5e31d0c0a80975a4d4bfbf129a3c6f0c44b5bd3070a |