
# tranche
ConfigParser with layered precedence, provenance, comment-preserving writes, and safe expressions.
The name **tranche** comes from the French word for *slice* — a nod to how the
library lets you cut cleanly through multiple configuration layers to get a
single, effective view of your settings.
## Documentation
Full docs: https://xylar.github.io/tranche/
## Install
- From PyPI (no NumPy):
```bash
pip install tranche
```
- With NumPy extras (to enable safe NumPy expressions):
```bash
pip install tranche[numpy]
```
- From source (local checkout):
```bash
pip install .
```
## Quick start
```python
from tranche import Tranche
config = Tranche()
config.add_from_file("defaults.cfg")
config.add_user_config("user.cfg")
# Simple values
value = config.get("core", "option")
# Expression (literal backend chosen automatically)
points = config.getexpression("plot", "ticks")
# NumPy expression (auto-selects safe backend because allow_numpy=True)
arr = config.getexpression("plot", "bins", allow_numpy=True)
# Or via convenience helper
arr2 = config.getnumpy("plot", "bins")
# Provenance
info = config.explain("plot", "bins")
print(info)
```
## Security notes
- Expressions default to `backend="literal"` for safety.
- The `safe` backend only allows a small AST subset and a very small set of symbols.
- NumPy is opt-in via `allow_numpy=True` and the `numpy` extra.
## Extensibility
You can add your own safe symbols:
```python
import math
config.register_symbol("sqrt", math.sqrt)
```
## Links
- Docs: https://xylar.github.io/tranche/
- Source: https://github.com/xylar/tranche
- Issues: https://github.com/xylar/tranche/issues
## License
BSD-3-Clause
Raw data
{
"_id": null,
"home_page": null,
"name": "tranche",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "config, configparser, layered, provenance, numpy, safe-eval",
"author": "Xylar Asay-Davis",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/d7/58/1c6f7ce57592d7d3564450da70c87185ed0767c83ca4cdb5f19b2bdc0828/tranche-0.3.0.tar.gz",
"platform": null,
"description": "\n\n# tranche\n\nConfigParser with layered precedence, provenance, comment-preserving writes, and safe expressions.\n\nThe name **tranche** comes from the French word for *slice* \u2014 a nod to how the\nlibrary lets you cut cleanly through multiple configuration layers to get a\nsingle, effective view of your settings.\n\n## Documentation\n\nFull docs: https://xylar.github.io/tranche/\n\n## Install\n\n- From PyPI (no NumPy):\n\n```bash\npip install tranche\n```\n\n- With NumPy extras (to enable safe NumPy expressions):\n\n```bash\npip install tranche[numpy]\n```\n\n- From source (local checkout):\n\n```bash\npip install .\n```\n\n## Quick start\n\n```python\nfrom tranche import Tranche\n\nconfig = Tranche()\nconfig.add_from_file(\"defaults.cfg\")\nconfig.add_user_config(\"user.cfg\")\n\n# Simple values\nvalue = config.get(\"core\", \"option\")\n\n# Expression (literal backend chosen automatically)\npoints = config.getexpression(\"plot\", \"ticks\")\n\n# NumPy expression (auto-selects safe backend because allow_numpy=True)\narr = config.getexpression(\"plot\", \"bins\", allow_numpy=True)\n\n# Or via convenience helper\narr2 = config.getnumpy(\"plot\", \"bins\")\n\n# Provenance\ninfo = config.explain(\"plot\", \"bins\")\nprint(info)\n```\n\n## Security notes\n\n- Expressions default to `backend=\"literal\"` for safety.\n- The `safe` backend only allows a small AST subset and a very small set of symbols.\n- NumPy is opt-in via `allow_numpy=True` and the `numpy` extra.\n\n## Extensibility\n\nYou can add your own safe symbols:\n\n```python\nimport math\nconfig.register_symbol(\"sqrt\", math.sqrt)\n```\n\n## Links\n\n- Docs: https://xylar.github.io/tranche/\n- Source: https://github.com/xylar/tranche\n- Issues: https://github.com/xylar/tranche/issues\n\n## License\n\nBSD-3-Clause\n",
"bugtrack_url": null,
"license": null,
"summary": "ConfigParser with layered precedence, provenance, comment-preserving writes, and safe expressions.",
"version": "0.3.0",
"project_urls": {
"Documentation": "https://xylar.github.io/tranche/",
"Homepage": "https://github.com/xylar/tranche",
"Issues": "https://github.com/xylar/tranche/issues"
},
"split_keywords": [
"config",
" configparser",
" layered",
" provenance",
" numpy",
" safe-eval"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "8ffce661d4eba4f10cfbd761bc6faf30a30eb4540b51656cdadf748ee779da7c",
"md5": "0351eb5eb669bc5d73689db6f67cc0b1",
"sha256": "d420ef63f5cce619c5a8ed0792c5406ca628ccd68a4359ce73ac87e4cbb1ba06"
},
"downloads": -1,
"filename": "tranche-0.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0351eb5eb669bc5d73689db6f67cc0b1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 13872,
"upload_time": "2025-11-04T13:38:48",
"upload_time_iso_8601": "2025-11-04T13:38:48.762692Z",
"url": "https://files.pythonhosted.org/packages/8f/fc/e661d4eba4f10cfbd761bc6faf30a30eb4540b51656cdadf748ee779da7c/tranche-0.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "d7581c6f7ce57592d7d3564450da70c87185ed0767c83ca4cdb5f19b2bdc0828",
"md5": "8759d860f95eda1fb202e05481e0bf42",
"sha256": "d820195dc9e47a2e131c4de6b9811ca866da1818c42100d4aa864ebffbb24d18"
},
"downloads": -1,
"filename": "tranche-0.3.0.tar.gz",
"has_sig": false,
"md5_digest": "8759d860f95eda1fb202e05481e0bf42",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 17748,
"upload_time": "2025-11-04T13:38:50",
"upload_time_iso_8601": "2025-11-04T13:38:50.176978Z",
"url": "https://files.pythonhosted.org/packages/d7/58/1c6f7ce57592d7d3564450da70c87185ed0767c83ca4cdb5f19b2bdc0828/tranche-0.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-11-04 13:38:50",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "xylar",
"github_project": "tranche",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "tranche"
}