Metadata-Version: 2.4
Name: pathext
Version: 1.2
Summary: A collection of functions working with `pathlib.Path`
Project-URL: Homepage, https://github.com/petamas/python-pathext
Project-URL: Bug Tracker, https://github.com/petamas/python-pathext/issues
Author-email: Tamás PEREGI <petamas@gmail.com>
License-Expression: MIT
License-File: LICENSE
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: OS Independent
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# 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 up `name` in. If set to `None`, or set to a string, then it is passed to `shutil.which()` as-is. If set to a list, concatenates the list items using `os.pathsep`, and passes the result to `shutil.which()`. Defaults to `None`. See `shutil.which()`'s documentation on exact behaviour of this argument.
- `cwd: Optional[Path]` - If specified, then changes the current working directory to `cwd` for the duration of the `shutil.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`.
