Metadata-Version: 2.4
Name: path-tools-med
Version: 0.1.0
Summary: A few path related functions I wish pathlib supported.
License-Expression: MIT
License-File: LICENSE
Author: Malcolm E. Davis
Author-email: malcolm3davis@gmail.com
Requires-Python: >=3.10
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Project-URL: Documentation, https://malcolm3davis.github.io/path-tools-med
Project-URL: Homepage, https://malcolm3davis.github.io/path-tools-med
Project-URL: Repository, https://github.com/malcolm3davis/path-tools-med
Description-Content-Type: text/markdown

# Malcolm's Path Tools

[![PyPI](https://img.shields.io/pypi/v/path-tools-med?style=flat-square)](https://pypi.python.org/pypi/path-tools-med/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/path-tools-med?style=flat-square)](https://pypi.python.org/pypi/path-tools-med/)
[![PyPI - License](https://img.shields.io/pypi/l/path-tools-med?style=flat-square)](https://pypi.python.org/pypi/path-tools-med/)
[![Coookiecutter - Malcolm](https://img.shields.io/badge/cookiecutter-Malcolm_Wolt-00c2e8?style=flat-square&logo=cookiecutter&logoColor=D4AA00&link=https://github.com/malcolm-3/malcolm-3-python-package-cookiecutter)](https://github.com/woltapp/wolt-python-package-cookiecutter)


---

**Documentation**: [https://malcolm3davis.github.io/path-tools-med](https://malcolm3davis.github.io/path-tools-med)

**Source Code**: [https://github.com/malcolm3davis/path-tools-med](https://github.com/malcolm3davis/path-tools-med)

**PyPI**: [https://pypi.org/project/path-tools-med/](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.

```python
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

```sh
pip install path-tools-med
```

## Development

* Clone this repository
* Requirements:
  * [Poetry](https://python-poetry.org/)
  * Python 3.8+
* Create a virtual environment and install the dependencies

```sh
poetry install
```

* Activate the virtual environment

```sh
poetry shell
```

### Testing

```sh
pytest
```

### Documentation

The documentation is automatically generated from the content of the [docs directory](https://github.com/malcolm3davis/path-tools-med/tree/master/docs) and from the docstrings
 of the public signatures of the source code. The documentation is updated and published as a [Github Pages page](https://pages.github.com/) automatically as part each release.

### Releasing

Trigger the [Draft release workflow](https://github.com/malcolm3davis/path-tools-med/actions/workflows/draft_release.yml)
(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](https://github.com/malcolm3davis/path-tools-med/releases) and publish it. When
 a release is published, it'll trigger [release](https://github.com/malcolm3davis/path-tools-med/blob/master/.github/workflows/release.yml) 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):

```sh
pre-commit install
```

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

```sh
pre-commit install -t pre-push
```

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

```sh
pre-commit run --all-files
```

---

This project was generated using the [wolt-python-package-cookiecutter](https://github.com/woltapp/wolt-python-package-cookiecutter) template.

