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.26.2.tar.gz
(19.8 kB
view details)
Built Distribution
File details
Details for the file click pathlib-2019.4.26.2.tar.gz
.
File metadata
- Download URL: click pathlib-2019.4.26.2.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 | 12a56d4167a1ad95b0a9810780defda7f12c8eecb7882db467ea45f0b14839fa |
|
MD5 | 81026bf27de310c8b0c15b6a50f816c8 |
|
BLAKE2b-256 | df7c641fe61c754129f982f4d87bd133cccd52bf233a66783c5c5b422220248e |
File details
Details for the file click_pathlib-2019.4.26.2-py3-none-any.whl
.
File metadata
- Download URL: click_pathlib-2019.4.26.2-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 | 249e43de467901ff4529f25f467de4d88c992ec55fe9ab6f62003106324fec75 |
|
MD5 | 3a7e1ffc3f6a7d7ab019c7cf923226c8 |
|
BLAKE2b-256 | 3462286d6418fa8b818ac5db2b1f0918294315662590b92cc28da77d31726146 |