Path Template
Install
poetry add pathtmpl
Usage
import uuid
from pathlib import PurePath
from datetime import date as Date
from pathtmpl import Context, get_evaluated_path
path_tmpl = """
/Tax/{{ year }}/{{ file_name }}
"""
context = Context(
id=uuid.uuid4(),
title="My Tax Declaration",
file_name="elster_doc.pdf",
category="Taxes",
year=2025,
month=12,
day=11,
)
ev_path = get_evaluated_path(context, path_template=path_tmpl)
assert ev_path == PurePath("/Tax/2025/elster_doc.pdf")
Another example:
import uuid
from pathlib import PurePath
from pathtmpl import Context, get_evaluated_path
context = Context(
file_name="receipt.pdf",
title="Receipt from ALDI",
id=uuid.uuid4(),
year=2025,
day=11,
month=12,
category="Grocery Receipts"
)
ev_path = get_evaluated_path(
context,
path_template="/{{ category }}/{{ year }}/{{ file_name }}",
)
expected_path = PurePath(
"/Grocery Receipts/2025/receipt.pdf"
)
assert PurePath(ev_path) == expected_path
In its simplest form:
import uuid
from pathlib import PurePath
from pathtmpl import Context, get_evaluated_path
context = Context(
title="coco",
id=uuid.uuid4(),
year=2025,
day=11,
month=12,
file_name="invoice.pdf",
category="Invoice"
)
ev_path = get_evaluated_path(context, path_template="/My Documents/Receipt/")
assert ev_path == "/My Documents/Receipt/"
Tests
poetry run pytest
Metadata
Release files for pathtmpl 0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pathtmpl-0.3.tar.gz | 2.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pathtmpl-0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 5.2 kB
Release files / pathtmpl-0.3.tar.gz
| Download URL | pathtmpl-0.3.tar.gz |
|---|---|
| Size | 2.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
adda5088499c80aed4cafaefce30a5d730b8d04e9cf0a7a71306428dbdae6626
|
|
BLAKE2b-256 checksum How to use checksums |
866f19df9471aad27054a515f862a25b503cccc15e41af985134f3d7e94c759f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.13.11 Linux/6.11.0-1018-azure
|
Release files / pathtmpl-0.3-py3-none-any.whl
| Download URL | pathtmpl-0.3-py3-none-any.whl |
|---|---|
| Size | 3.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
889efe92aaeb3ab072837b73b9ede395444bc44abe94a66d8fae8b95c931eef3
|
|
BLAKE2b-256 checksum How to use checksums |
8a3b635d887051518dd70422c68936c9e08daf5d89845463f09b5f9717c5dc51
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.13.11 Linux/6.11.0-1018-azure
|
Security for pathtmpl 0.3
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.