A collection of functions working with `pathlib.Path`
Project description
pathext
pathext is a collection of functions working with pathlib.Path. They're often wrappers for standard library functionality with some extensions.
Executable lookup
pathext.which()
Wrapper for shutil.which() which returns the result as an absolute Path (or None if it fails to find the executable). It also has a couple extra features, see below.
Arguments (all of them except name are optional):
name: str- Executable name to look up.path: None | str | Sequence[Path]- Directory list to look upnamein. If set toNone, or set to a string, then it is passed toshutil.which()as-is. If set to a list, concatenates the list items usingos.pathsep, and passes the result toshutil.which(). Defaults toNone. Seeshutil.which()'s documentation on exact behaviour of this argument.cwd: Optional[Path]- If specified, then changes the current working directory tocwdfor the duration of theshutil.which()call. Note that since it is changing global state (the current working directory), it is inherently not thread-safe.
pathext.checked_which()
Same as pathext.which(), except it raises ValueError instead of returning None if it cannot find the executable.
Generic utilities
pathext.to_path()
Simple function that converts a str to a Path (just like Path's constructor), but also handles None by returning None. It can be used to convert the return value of functions that return str | None to Path | None.
Project details
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pathext-1.0.tar.gz.
File metadata
- Download URL: pathext-1.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5833cb54e33e142097d7269b761a3fa323a393e9925f0703181707656bff166
|
|
| MD5 |
0ebeba237b3b8674165dfe8e2c904e61
|
|
| BLAKE2b-256 |
8689761ee937ca14c4675e5bef0715118219c76d0ef9c5bab964cb53feacc286
|
File details
Details for the file pathext-1.0-py3-none-any.whl.
File metadata
- Download URL: pathext-1.0-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2702b80f3e1ba35c24d1c5e480002b002a3d0bf3b7f3499113191648ffcd85f3
|
|
| MD5 |
1ae255fb095cfb57c004c842e93074fb
|
|
| BLAKE2b-256 |
7ed0030d2b5e4e83c743c7d24cb358b1d6822868b38f06f51ff6214dc6182a16
|