'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
Built Distribution
File details
Details for the file click-pathlib-2019.12.28.7.tar.gz
.
File metadata
- Download URL: click-pathlib-2019.12.28.7.tar.gz
- Upload date:
- Size: 19.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9edaf8e92bbe622a62417f2f6a1fb69ad388a9d1d977b7b692dc45d910f37abc |
|
MD5 | e54413463676361a6952813f4459c4e8 |
|
BLAKE2b-256 | 294bf6b7f5db8119e8e501fd693171f4aabc7c74b30573e8ac5e57fdfd756c29 |
File details
Details for the file click_pathlib-2019.12.28.7-py3-none-any.whl
.
File metadata
- Download URL: click_pathlib-2019.12.28.7-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6b037a05c97fb4d29536b95c2cf50c750fe5413dd6cf1cece119286eba6ae6b |
|
MD5 | 45e492eb7932beba6e138ce8036bbf3d |
|
BLAKE2b-256 | 81b23412631c570878da7930ca2de8bb4847f07822576cf32d94cb8a7e118a60 |