Templated paths using t-strings
Project description
wend
A library for templated paths using Python t-strings (3.14+)
Installation
uv pip install wend
Requirements
- Python 3.14+
About
For backstory read my blog about this package cog.spin.systems/future-paths!
The general idea is to use t-strings to house eagerly instantiated parameter objects which offer a form of deferred execution.
Usage
Following the examples in the blog post:
from pathlib import Path
from wend import Param, P, T, RelativePath
# Define parameters (late-bound)
root = Param("root")
dataset = Param("dataset")
idx = Param("idx")
total = Param("total")
# Build expressions - these don't touch the filesystem
data_dir = root / "data" / dataset
chunk_file = data_dir / T(t"chunk_{idx:04d}-of-{total:04d}.parquet")
# Inspect what's needed
print("Required params:", chunk_file.required_params())
# -> {'root', 'dataset', 'idx', 'total'}
# Resolve with bindings
path = chunk_file.resolve({
"root": "/mnt/storage",
"dataset": "train",
"idx": 7,
"total": 100,
})
print("Resolved:", path)
# -> /mnt/storage/data/train/chunk_0007-of-0100.parquet
# Constant folding happens at construction
folded = P("/home") / "user" / "data"
print("Folded type:", type(folded).__name__)
# -> LiteralExpr (not nested JoinExprs)
# Parent simplification
expr = root / "a" / "b"
print("Parent of join:", expr.parent)
# -> JoinExpr(ParamExpr, LiteralExpr("a")) -- the "b" is gone structurally
# Suffix chain collapse
double_suffix = (root / "file.txt").with_suffix(".tmp").with_suffix(".json")
print("Suffix chain:", double_suffix)
# -> WithSuffixExpr(base=JoinExpr(...), suffix='.json') -- .tmp is gone
# Connectivity: rebasing
config = RelativePath(
base=root,
relative=P("config") / "settings.yaml"
)
print("Config path:", config.resolve({"root": "/project"}))
# -> /project/config/settings.yaml
# Rebase to test environment
test_config = config.rebase(P("/tmp/test"))
print("Test config:", test_config.resolve({}))
# -> /tmp/test/config/settings.yaml
Contributing
Contributions are welcome! Please:
- Open an issue to discuss bugs or feature requests
- Fork the repo and submit a PR for changes
- Install dev dependencies with
uv syncand runpre-commit install
License
MIT License - see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wend-0.1.1.tar.gz.
File metadata
- Download URL: wend-0.1.1.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98ffc45961f783d697b53eb39c905011c50822424531fc00b2e75c6f0eff542a
|
|
| MD5 |
5c4db94eb6fce227c87450796e508b1d
|
|
| BLAKE2b-256 |
9aacfa914cf2d5504d4f62e04e874216802d9555f0c4b5eab4664057c6ea7717
|
Provenance
The following attestation bundles were made for wend-0.1.1.tar.gz:
Publisher:
CI.yml on lmmx/wend
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wend-0.1.1.tar.gz -
Subject digest:
98ffc45961f783d697b53eb39c905011c50822424531fc00b2e75c6f0eff542a - Sigstore transparency entry: 908795284
- Sigstore integration time:
-
Permalink:
lmmx/wend@a35d7cc8ef81333ef099dfcb7226384531a51fac -
Branch / Tag:
refs/heads/master - Owner: https://github.com/lmmx
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
CI.yml@a35d7cc8ef81333ef099dfcb7226384531a51fac -
Trigger Event:
workflow_run
-
Statement type:
File details
Details for the file wend-0.1.1-py3-none-any.whl.
File metadata
- Download URL: wend-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca6d8f858a3490580f20dec73510934ca272e81adf58b0ee078ddccde47b989e
|
|
| MD5 |
1b07f680e4b695ee18172bc0b4fb1c22
|
|
| BLAKE2b-256 |
fad747220a06f4935f9b10081f15cd36b876e808c7be4efaf6ff403277b013fd
|
Provenance
The following attestation bundles were made for wend-0.1.1-py3-none-any.whl:
Publisher:
CI.yml on lmmx/wend
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wend-0.1.1-py3-none-any.whl -
Subject digest:
ca6d8f858a3490580f20dec73510934ca272e81adf58b0ee078ddccde47b989e - Sigstore transparency entry: 908795287
- Sigstore integration time:
-
Permalink:
lmmx/wend@a35d7cc8ef81333ef099dfcb7226384531a51fac -
Branch / Tag:
refs/heads/master - Owner: https://github.com/lmmx
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
CI.yml@a35d7cc8ef81333ef099dfcb7226384531a51fac -
Trigger Event:
workflow_run
-
Statement type: