'A Python click type which is similar to click.Path but returns a pathlib Path'
Project description
Click Pathlib
A Python click type which is similar to click.Path but returns a Pathlib.Path.
Installation
$ pip install click-pathlib
This supports Python 3.8+.
Usage
Use the click_pathlib.Path just like a click.Path type and your function will receive a pathlib.Path.
import click
import click_pathlib
@click.command('delete')
@click.argument(
'existing_file',
type=click_pathlib.Path(exists=True),
)
def delete(existing_file):
existing_file.unlink()
Credits
Thanks to @jeremyh for describing this solution on GitHub at https://github.com/pallets/click/issues/405#issuecomment-470812067.
Contributing
See CONTRIBUTING.rst.
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
click-pathlib-2020.3.13.0.tar.gz
(15.6 kB
view details)
Built Distribution
File details
Details for the file click-pathlib-2020.3.13.0.tar.gz
.
File metadata
- Download URL: click-pathlib-2020.3.13.0.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e74a7a209699107d6aa884b3070e1f81e67dea10acf2244fbd3a4eafad207c1c |
|
MD5 | 7cdfb9bdc1e3b6ba30cd3f31b76e8698 |
|
BLAKE2b-256 | 38fe0ed987a20b4b691b315b04b6a7ea58f0f5a052791b25be024da96d0519b3 |
File details
Details for the file click_pathlib-2020.3.13.0-py3-none-any.whl
.
File metadata
- Download URL: click_pathlib-2020.3.13.0-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37faab20677ce754176378cd9be82fd9e7e28b5d5fa4f1cc89613cb6b9fe9d97 |
|
MD5 | 4806dc7bf623bad01365a80c776bf511 |
|
BLAKE2b-256 | 45930e132a0e8224780ef0586aa3b085252e0b95e54998d6c71dd71ab69d54f3 |