Skip to main content

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 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.

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

pathext-1.1.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pathext-1.1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file pathext-1.1.tar.gz.

File metadata

  • Download URL: pathext-1.1.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

Hashes for pathext-1.1.tar.gz
Algorithm Hash digest
SHA256 168f75f51ebb49bf17ccd8681bb57f1b6d38a51ec3998bc826cddd12e81375dc
MD5 0a9a243a7f9be6d8c37652222542c397
BLAKE2b-256 10fff3a7de2d8f87825f8c0a1218f8afa00b980f21c7f454c489495e313401df

See more details on using hashes here.

File details

Details for the file pathext-1.1-py3-none-any.whl.

File metadata

  • Download URL: pathext-1.1-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

Hashes for pathext-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 05b08f1c5fd3896b03b1c0ee44afcaf54fa3821d7613d4b5e1d9fc0833bccaf3
MD5 c8155f4adaed9bed522693fc5cbbcea1
BLAKE2b-256 c5fcbab57821abaeece1b797ada16dcabad11d4bcd78b0d98b29b674bb00735e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page