Skip to main content

A few path related functions I wish pathlib supported.

Project description

Malcolm's Path Tools

PyPI PyPI - Python Version PyPI - License Coookiecutter - Malcolm


Documentation: https://malcolm3davis.github.io/path-tools-med

Source Code: https://github.com/malcolm3davis/path-tools-med

PyPI: https://pypi.org/project/path-tools-med/


A few path related functions I wish pathlib supported.

Usage

  • make_versioned_backup(path: Path|str) -> Path
    • Renames the specified path adding a .~#~ style version number that is higher than any existing version number.
  • backup_path(paht: Path|str, backup_extension=".bak") -> Path
    • Renames the specified file adding the backup_extension. If that backup file already exists it renamed with make_versioned_backup.
  • get_highest_backup_version(path: Path|str) -> int
    • Utility function to see what the current highest backup version number exists.

It also provides the PathRerooter class that can be used to update path objects to have a new initial root path.

r = PathRerooter("/old/root/path", "/new/root/path/is/here")
assert r.fix("/old/root/path/some/file.txt") == "/new/root/path/is/here/some/file.txt"

Installation

pip install path-tools-med

Development

  • Clone this repository
  • Requirements:
  • Create a virtual environment and install the dependencies
poetry install
  • Activate the virtual environment
poetry shell

Testing

pytest

Documentation

The documentation is automatically generated from the content of the docs directory and from the docstrings of the public signatures of the source code. The documentation is updated and published as a Github Pages page automatically as part each release.

Releasing

Trigger the Draft release workflow (press Run workflow). This will update the changelog & version and create a GitHub release which is in Draft state.

Find the draft release from the GitHub releases and publish it. When a release is published, it'll trigger release workflow which creates PyPI release and deploys updated documentation.

Pre-commit

Pre-commit hooks run all the auto-formatting (ruff format), linters (e.g. ruff and mypy), and other quality checks to make sure the changeset is in good shape before a commit/push happens.

You can install the hooks with (runs for each commit):

pre-commit install

Or if you want them to run only for each push:

pre-commit install -t pre-push

Or if you want e.g. want to run all checks manually for all files:

pre-commit run --all-files

This project was generated using the wolt-python-package-cookiecutter template.

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

path_tools_med-0.1.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

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

path_tools_med-0.1.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file path_tools_med-0.1.0.tar.gz.

File metadata

  • Download URL: path_tools_med-0.1.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.13 Linux/6.17.0-1020-azure

File hashes

Hashes for path_tools_med-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8ded949cb44beb461318cef74d38cac1ee7dc1d3ff5b0b0599be802fda35e897
MD5 3185d73dd36fd18af67fca38468ec089
BLAKE2b-256 b00d77010be3168355f6c74e76f2e4eb4ec21d05225291942205a7651744c4a3

See more details on using hashes here.

File details

Details for the file path_tools_med-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: path_tools_med-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.13 Linux/6.17.0-1020-azure

File hashes

Hashes for path_tools_med-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1159aa9a7d02a4480a3db392ab00f350440c26875059cc174cb2770acde70dc9
MD5 eeda0b2a016dfe27d88b19028bb70184
BLAKE2b-256 c656294a39cf2d43c548e8834c59eea8d1f18385b0373b50e49a032e276905e2

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