regma
String templates with dataclass style
regma lets you define string templates through models behaving like standard dataclass.
It aims at solving a common scenario in the VFX/animation industry where we need to construct file paths from tokens and extract tokens from file paths.
regma lets you define the structure of your strings from typed fields and will handle for you:
- formatting of your model instances to string
- parsing of a string to model instances
Features
- Dataclass like structure: your models are properly typed and subclassable
- Typed fields:
string,integer,choice - Reference to other models: using annotations or using the
referencefield - Field validation: fields are validated both during formatting and parsing. Strictness can be configured in both directions independently
- Configurable delimiters:
{},<>,[]; global or per-model - Great developer experience: common linter and static type checker are supported. Most common IDEs (VS Code, PyCharm) provide autocompletion
Concrete example
from regma import TemplateModel
from regma import string, choice, integer
class Asset(TemplateModel):
type: str = choice(["chr", "prp", "set"])
code: str = string(r"[a-z][a-z0-9]+")
template = "{type}_{code}"
# Create an asset from its fields
asset = Asset("chr", "foo")
# Get it as a string
asset_str = asset.format() # or using str(asset)
# Parse an asset from its string
parsed_asset = Asset.parse("chr_foo")
# Build a more complex example to build a path
class GroomRetargetInfoPath(TemplateModel):
source_asset: Asset
target_asset: Asset
groom_name: str = string(r"[a-z][a-z0-9]+")
template = (
"/root/assets/{target_asset.type}/{target_asset}/{asset_target}_{groom}_{asset_target}.json"
)
# Create a new model
groom_info = GroomRetargetInfoPath(Asset("chr", "foo"), Asset("chr", "bar"), "hair")
# Get it as string
groom_info_path = groom_info.format() # /root/assets/chr/chr_foo/chr_foo_hair_chr_bar.json
# Parse the path to its information
parsed_groom_info = GroomRetargetInfoPath.parse("/root/assets/chr/chr_foo/chr_foo_hair_chr_bar.json")
License
MIT
Metadata
Release files for regma 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| regma-0.0.1.tar.gz | 81.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| regma-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 94.6 kB
Release files / regma-0.0.1.tar.gz
| Download URL | regma-0.0.1.tar.gz |
|---|---|
| Size | 81.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
45d0f30789b51c72c1f69662f5b3fc1d0935c040685bfe5dfecc1f6a835b48ba
|
|
BLAKE2b-256 checksum How to use checksums |
1e785875a031ae7026ccf4cb5333983cc4a996af080109d8d280a70e48d5ccad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 24, 2026.
Transparency logRelease files / regma-0.0.1-py3-none-any.whl
| Download URL | regma-0.0.1-py3-none-any.whl |
|---|---|
| Size | 12.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a22e4abd07639aa8bbd03dfa9bfa1cd8bfa57d26f00419ae3bc13c97e2ee0fae
|
|
BLAKE2b-256 checksum How to use checksums |
768cb57efc56b371ec902c07968c503a145f86a09c854338d49477a06d2740e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 24, 2026.
Transparency log