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.5+.
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-2019.4.30.1.tar.gz
(19.8 kB
view details)
Built Distribution
File details
Details for the file click-pathlib-2019.4.30.1.tar.gz
.
File metadata
- Download URL: click-pathlib-2019.4.30.1.tar.gz
- Upload date:
- Size: 19.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0f163ae33de838650543e4127ff979b81c848ee7f1756cb1a59063a6964655a |
|
MD5 | a5bc17930361cca37d6bb00102ea7be6 |
|
BLAKE2b-256 | 0726e08257525d46733d6623e262ee812270ed3920da64ee8bd4e2b6519eabe4 |
File details
Details for the file click_pathlib-2019.4.30.1-py3-none-any.whl
.
File metadata
- Download URL: click_pathlib-2019.4.30.1-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b2772dfb3647cf313e753fa8dae3cf89d06d9c6933739e58a1450722cfd5312 |
|
MD5 | 81508f55b3631588ce035ad934e54f9a |
|
BLAKE2b-256 | c64e4c9c86b6022b49041bc191f84fb88214e956c0796e414ecd14bf3b92499d |