Skip to main content

Subtrix

    ## Project overview
    
    Subtrix is a substitution module for Python, providing powerful tools for text
    manipulation through substitutions. The main interface is the `Mechanism` class,
    which allows for standard substitution, term expansion, and variable
    substitution.
    
    Subtrix is part of the Solutions Brewer (SB) stack and is consumed by sibling
    projects such as **GoaLT** (report rendering) and **Condor** (prompt
    templating). It is designed to be:
    
    - **Deterministic** — given the same template and data, output is byte-stable.
    - **Composable** — the public API is a single class with a small surface.
    - **Safe** — built-in security validation (max size, max recursion, dangerous
      pattern deny-list).
    - **Lightweight** — minimal dependencies, no template precompilation step.
    
    See [ARCHITECTURE.md](ARCHITECTURE.md) for the full design and
    [CLI.md](CLI.md) for the command-line interface.
    
    ## Features
    
    - Provides a basic substitution mechanism
    - Supports variable substitution
    - Supports lists of variables to generate multiple documents from a single template
    - Supports term expansion by using term looping substitution all combinations of a list of terms can be generated
    - Provides Prefix and Suffix Support with controls for trailing suffix
    
    ## Installation
    
    You can install Subtrix via pip:
    
    ```bash
    pip install subtrix
    ```
    
    Alternatively, clone the repository and install from source:
    
    ```bash
    git clone https://github.com/solubrew/subtrix.git
    cd subtrix
    pip install -e .
    ```
    
    ### Requirements
    
    - Python 3.<MIN_VERSION> or higher
    - Dependencies: re, <EVAL_LIB> (automatically installed via pip where applicable)
    
    ## Quick Start
    
    Import the module and use the Mechanism class for substitutions:
    
    ## Standard Patterns
    
    ### Substitution:
    
        <[token]>: basic substitution
        <~[token]~>: optional token substituion (is removed if unused in template render)
        <[prefix.:token]>: token substitution with prefix
        <[token:.suffix]>: token substitution with suffix
    
    ### Variable Substitution:
    
        <(token)>: registerd variable lookup for things like TODAY, USER, etc.
        <(prefix.:token)>: optional variable token substituion
        <(token:.suffix)>: optional variable token substituion
    
    ### Looped Variable Substitution:
    
        token: ['point0', 'point1']
        <@[token]@>: [['point0'], ['point1'], ['point0', 'point1']
    
    ```python
    from subtrix import Mechanism
    
    # Initialize Mechanism
    template = 'Hello, <[name]>!'
    data = {'name': 'World'}
    mech = Mechanism(template, data)
    
    # Perform standard substitution
    result = mech.run()
    print(result)  # Output: Hello, World!
    ```
    
    ## Usage
    
    
    ### Variable Substitution
    
    Inject variables from various sources:
    
    
    ## Development
    
    To set up a development environment and run the test suite locally:
    
    ```bash
    # Clone and install in editable mode with dev extras
    git clone https://github.com/solubrew/subtrix.git
    cd subtrix
    python -m pip install --upgrade pip
    pip install -e ".[dev]"
    pip install pytest pytest-asyncio
    
    # Run the test suite
    pytest tests/ -v
    
    # Lint (matches CI)
    ruff check subtrix/
    
    # Confirm the package imports cleanly
    python -c "import subtrix; print('Import OK:', subtrix.__name__)"
    
    # Render a template from the CLI
    python -m subtrix.cli subtrix "Hello <[name]>!" '{"name": "World"}'
    ```
    
    Before opening a pull request, also run the compliance auditor to verify the
    project is in a releasable state:
    
    ```bash
    PYTHONPATH=...:$TASKAXN_PYTHONPATH python -m sasquatch.cli analyze \
        -p . --agent m3rl1n --skip-pii-secrets
    ```
    
    A score of **>= 90 %** is required to tag a release. See
    [CI_CD.md](CI_CD.md) for the full pipeline description.
    
    ## Contributing
    
    Contributions are welcome! Please follow these steps:
    
    1. Fork the repository.
    2. Create a feature branch (`git checkout -b feature/<FEATURE_NAME>`).
    3. Commit your changes (`git commit -am 'Add some feature'`).
    4. Push to the branch (`git push origin feature/<FEATURE_NAME>`).
    5. Open a Pull Request.
    
    See [CONTRIBUTING.md](CONTRIBUTING.md) for more details.
    
    ## License
    
    This project is licensed under the MIT License - see the [LICENSE](LICENSE.rst) file for details.
    
    ## Acknowledgments
    
    - Built with inspiration from open-source templating and substitution libraries.
    - Thanks to contributors of underlying libraries like re, and Python's built-in eval.

Metadata

Release files for subtrix 0.0.1.post5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for subtrix 0.0.1.post5
File Size Uploaded Provenance Actions
subtrix-0.0.1.post5.tar.gz 25.3 kB Without provenance Details for subtrix-0.0.1.post5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for subtrix 0.0.1.post5
File Interpreter ABI Platform Actions
subtrix-0.0.1.post5-cp312-cp312-manylinux_2_39_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.39+ x86-64 Details for subtrix-0.0.1.post5-cp312-cp312-manylinux_2_39_x86_64.whl

Total release size: 58.2 kB

Release files / subtrix-0.0.1.post5.tar.gz

Download URL subtrix-0.0.1.post5.tar.gz
Size 25.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f646a6898ba4402a8b88e72988cb3ccda0054e724b13d64b564392c4eb5f4cd1
BLAKE2b-256 checksum
How to use checksums
138ac99477902c052a9587db34b3b45d905a8f613ee11ed0c76d411e2cf5840b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / subtrix-0.0.1.post5-cp312-cp312-manylinux_2_39_x86_64.whl

Download URL subtrix-0.0.1.post5-cp312-cp312-manylinux_2_39_x86_64.whl
Size 32.9 kB
Tags CPython 3.12 Linux glibc 2.39+ x86-64
SHA-256 checksum
How to use checksums
bf58da88724cf5a5831c5b2ebe06e9186a208634943b06d81da9b29c24c87882
BLAKE2b-256 checksum
How to use checksums
319894d1f92e47d71a298417eadd087dad9f381cdeaab2b72d6760e348b38edf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for subtrix 0.0.1.post5

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page