Skip to main content

PathMonkey

PathMonkey is a lightweight, cross-platform Python utility that simplifies path manipulation. It supports advanced path construction and deconstruction for both Linux and Windows, making it easier to handle paths reliably across different operating systems.

Features

  • Construct paths from a list of components (e.g., ['~', 'projects', 'example']).
  • Deconstruct paths into individual components, with support for:
    • Home directory (~)
    • Windows drive letters (C:)
    • Absolute and relative paths
  • Handles edge cases like trailing slashes, mixed separators, and empty paths.
  • Built on Python's modern pathlib for robust path handling.

Installation

Install PathMonkey from PyPI using pip:

pip install pathmonkey

Usage

Here's how to use PathMonkey in your Python project:

Import the Module

from pathmonkey.pathmonkey import PathMonkey
from pathlib import Path

Constructing Paths

# Construct a path relative to the home directory
path = PathMonkey.construct_path(['~', 'projects', 'example'])
print(path)  # Output: /home/user/projects/example (on Linux)

# Construct an absolute path
path = PathMonkey.construct_path(['/', 'usr', 'bin'])
print(path)  # Output: /usr/bin

# Construct a Windows path
path = PathMonkey.construct_path(['C:', 'Users', 'example'])
print(path)  # Output: C:\Users\example

Deconstructing Paths

# Deconstruct a path relative to the home directory
components = PathMonkey.deconstruct_path(Path.home().joinpath('projects', 'example'))
print(components)  # Output: ['~', 'projects', 'example']

# Deconstruct an absolute path
components = PathMonkey.deconstruct_path(Path('/usr/bin'))
print(components)  # Output: ['', 'usr', 'bin']

# Deconstruct a Windows path
components = PathMonkey.deconstruct_path(Path('C:\\Users\\example'))
print(components)  # Output: ['C:', 'Users', 'example']

Examples

Path Construction

examples = [
    (['~', 'projects', 'example'], "Home directory relative"),
    (['/', 'usr', 'bin'], "Root directory"),
    (['', 'usr', 'bin'], "Absolute path from root"),
    (['C:', 'Users', 'example'], "Windows drive letter"),
    (['..', 'another_folder'], "Relative path"),
    (['usr', 'bin'], "Additional relative path"),
]

for elements, description in examples:
    path = PathMonkey.construct_path(elements)
    print(f"{description}: {path}")

Path Deconstruction

paths = [
    (Path.home().joinpath('projects', 'example'), "Home directory relative"),
    (Path('/usr/bin'), "Root directory"),
    (Path('usr/bin'), "Relative path"),
    (Path('C:\\Users\\example'), "Windows drive letter"),
]

for path, description in paths:
    components = PathMonkey.deconstruct_path(path)
    print(f"{description}: {components}")

Contributing

Contributions are welcome! To contribute:

  1. Fork the repository on GitHub.
  2. Create a feature branch (git checkout -b feature-name).
  3. Commit your changes (git commit -m 'Add new feature').
  4. Push to the branch (git push origin feature-name).
  5. Open a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Links


Metadata

Release files for pathmonkey 0.0.1

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

Source distribution (sdist)

Source distribution for pathmonkey 0.0.1
File Size Uploaded Provenance
pathmonkey-0.0.1.tar.gz 4.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pathmonkey 0.0.1
File Interpreter ABI Platform
pathmonkey-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 9.7 kB

Release files / pathmonkey-0.0.1.tar.gz

Download URL pathmonkey-0.0.1.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e4766fea4cde4819a2a170229295869181143aea2140ca0f6449248f8a014571
BLAKE2b-256 checksum
How to use checksums
6194cc2a58ba08ca3b309be19a5b96ac004e09ed9a4d8cca5a100ba1e0f62a40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.3

Release files / pathmonkey-0.0.1-py3-none-any.whl

Download URL pathmonkey-0.0.1-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
17f419c6282d73d535d78cf9bd6aa797cd7b51bb684ef8cfcdbeeac9e65b64c0
BLAKE2b-256 checksum
How to use checksums
ab0489ca8c08600f29ce06fa819ad8daec7d943d05bae69dca7f7fa0c083a8e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.3

Security for pathmonkey 0.0.1

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

0.0.1 This release

2 release files No provenance

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