Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

fspathverbs

A Python package for representing filesystem paths as a sequence of verbs.

What makes fspathverbs unique?

Unlike traditional libraries that treat filesystem paths as nouns, fspathverbs views filesystem paths as a sequence of verbs:

  • Root(root): Step to the root directory root.
  • Parent: Step to the parent directory.
  • Current: Step to the current directory.
  • Child(child): Step to the child child (file or directory).
import ntpath
import posixpath
from fspathverbs import Root, Parent, Current, Child, compile_to_fspathverbs

# NT path test cases
assert compile_to_fspathverbs(path='', split=ntpath.split) == [Current()]
assert compile_to_fspathverbs(path='C:\\Users\\Alice\\Documents', split=ntpath.split) == [
    Root(root='C:\\'),
    Child(child='Users'),
    Child(child='Alice'),
    Child(child='Documents')
]
assert compile_to_fspathverbs(path='D:notes\\todo.txt', split=ntpath.split) == [
    Root(root='D:'),
    Child(child='notes'),
    Child(child='todo.txt')
]
assert compile_to_fspathverbs(path='\\server\\share\\folder\\', split=ntpath.split) == [
    Root(root='\\'),
    Child(child='server'),
    Child(child='share'),
    Child(child='folder'),
    Current()
]
assert compile_to_fspathverbs(path='.\\subdir\\file', split=ntpath.split) == [
    Current(),
    Current(),
    Child(child='subdir'),
    Child(child='file')
]
assert compile_to_fspathverbs(path='..\\backup\\..\\archive', split=ntpath.split) == [
    Current(),
    Parent(),
    Child(child='backup'),
    Parent(),
    Child(child='archive')
]
# Absolute path with mixed slashes
assert compile_to_fspathverbs(path='C:/weird\\mix/format', split=ntpath.split) == [
    Root(root='C:/'),
    Child(child='weird'),
    Child(child='mix'),
    Child(child='format')
]
# UNC path with share, trailing slash
assert compile_to_fspathverbs(path='\\\\network-pc\\storage\\docs\\', split=ntpath.split) == [
    Root(root='\\\\network-pc\\storage\\'),
    Child(child='docs'),
    Current()
]
# Device path
assert compile_to_fspathverbs(path='\\\\.\\COM56\\logs', split=ntpath.split) == [
    Root(root='\\\\.\\COM56\\'),
    Child(child='logs')
]

# POSIX path test cases
assert compile_to_fspathverbs(path='', split=posixpath.split) == [Current()]
assert compile_to_fspathverbs(path='/', split=posixpath.split) == [Root(root='/')]
assert compile_to_fspathverbs(path='/alpha/beta/gamma', split=posixpath.split) == [
    Root(root='/'),
    Child(child='alpha'),
    Child(child='beta'),
    Child(child='gamma')
]
assert compile_to_fspathverbs(path='delta/epsilon', split=posixpath.split) == [
    Current(),
    Child(child='delta'),
    Child(child='epsilon')
]
assert compile_to_fspathverbs(path='/foo/./bar/../baz/', split=posixpath.split) == [
    Root(root='/'),
    Child(child='foo'),
    Current(),
    Child(child='bar'),
    Parent(),
    Child(child='baz'),
    Current()
]
assert compile_to_fspathverbs(path='./theta/../iota', split=posixpath.split) == [
    Current(),
    Current(),
    Child(child='theta'),
    Parent(),
    Child(child='iota')
]

Installation

pip install fspathverbs

What are the benefits?

  • Correctness: Traditional path simplification (e.g., collapsing foo/../bar to bar) can be incorrect if foo is a file and not a directory. fspathverbs allows you to validate each navigation step as it happens, ensuring your code reflects the actual structure of the filesystem.
  • Security: Treating paths as a series of verbs helps prevent path traversal vulnerabilities (such as escaping a sandbox via ..). Each verb can be checked against permissions and boundaries, stopping exploits before they occur.
  • Clarity: Verbs are explicit, making path handling transparent and auditable.
  • Novelty: To our knowledge, this is the first open-source library that represents filesystem paths as a sequence of verbs, rather than just strings or string wrappers. This fills a long-standing gap in filesystem path modeling.

Contributing

Contributions are welcome! Please submit pull requests or open issues on the GitHub repository.

License

This project is licensed under the MIT License.

Metadata

Release files for fspathverbs 0.1.0a0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fspathverbs 0.1.0a0
File Size Uploaded Provenance
fspathverbs-0.1.0a0.tar.gz 4.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for fspathverbs 0.1.0a0
File Interpreter ABI Platform
fspathverbs-0.1.0a0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 8.6 kB

Release files / fspathverbs-0.1.0a0.tar.gz

Download URL fspathverbs-0.1.0a0.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
eab83e9da7ca1e4789f0a738f8b13997b03986a0c13e8e4b3d4ebb59627950b3
BLAKE2b-256 checksum
How to use checksums
d7e18353e5be2cb0a4ac41aceb1eabf5c3b67260a667f81c878ce449b3a5852f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / fspathverbs-0.1.0a0-py2.py3-none-any.whl

Download URL fspathverbs-0.1.0a0-py2.py3-none-any.whl
Size 4.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
73f66498c6a1418c1e04a6a80feb11ec99a7b229c3c59d58e878c23ca0261076
BLAKE2b-256 checksum
How to use checksums
11a8286a7276a3a4f54eee2873f0db7f1599a3859e104ec2caef090328cc7774
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Security for fspathverbs 0.1.0a0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page