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.6.13.1.tar.gz
(19.9 kB
view details)
Built Distribution
File details
Details for the file click-pathlib-2019.6.13.1.tar.gz
.
File metadata
- Download URL: click-pathlib-2019.6.13.1.tar.gz
- Upload date:
- Size: 19.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a62babe7a52c34d00f64cc199442cebf68ccc067443e93a22e5ca3ee99785e6b |
|
MD5 | 052e3de5876975e0c8b4c182340d3c00 |
|
BLAKE2b-256 | 2c146e4a9e9efc10ff0e8566c6f05b5c166c59fb13873bf25e76422a83c45fba |
File details
Details for the file click_pathlib-2019.6.13.1-py3-none-any.whl
.
File metadata
- Download URL: click_pathlib-2019.6.13.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.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8aca6ba569298881c5d978e9af284d489338b55c7c10cdd9680e66ec28993373 |
|
MD5 | 788290c2edf4692946e68dcfc0b889f3 |
|
BLAKE2b-256 | 8a090693d862e08dc83c1fbf7d36f2f6267e5f103e31e5f7e8cc939ca1f5cdb2 |