
# 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)
points = config.getexpression("plot", "ticks", backend="literal")
# Expression (safe with numpy)
arr = config.getexpression("plot", "bins", backend="safe", allow_numpy=True)
# 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/2a/4e/e8cf91d24c138bfccb5ab0ca068ae1cb6e3a1ab67d62b211da91e5893f8a/tranche-0.1.1.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)\npoints = config.getexpression(\"plot\", \"ticks\", backend=\"literal\")\n\n# Expression (safe with numpy)\narr = config.getexpression(\"plot\", \"bins\", backend=\"safe\", allow_numpy=True)\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.1.1",
"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": "2ae3eb54f29471247edc9ebcc2a40518d32e4db58a8a6940e7f37b6173539686",
"md5": "820dc5c6c95285870183b2633469aeb9",
"sha256": "600392f021d5c4379fcb9d4603b0cdeeb8c1ed9f8f5502db601077a44204bab4"
},
"downloads": -1,
"filename": "tranche-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "820dc5c6c95285870183b2633469aeb9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 11813,
"upload_time": "2025-09-12T09:21:54",
"upload_time_iso_8601": "2025-09-12T09:21:54.203405Z",
"url": "https://files.pythonhosted.org/packages/2a/e3/eb54f29471247edc9ebcc2a40518d32e4db58a8a6940e7f37b6173539686/tranche-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "2a4ee8cf91d24c138bfccb5ab0ca068ae1cb6e3a1ab67d62b211da91e5893f8a",
"md5": "5b787a7d0f644a0be1c013a8f6bbab53",
"sha256": "b93272cd3f4da5b91f2c330c13bbd3c3f898fc6deb72f22c1b80dad9604f4506"
},
"downloads": -1,
"filename": "tranche-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "5b787a7d0f644a0be1c013a8f6bbab53",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 15633,
"upload_time": "2025-09-12T09:21:55",
"upload_time_iso_8601": "2025-09-12T09:21:55.346888Z",
"url": "https://files.pythonhosted.org/packages/2a/4e/e8cf91d24c138bfccb5ab0ca068ae1cb6e3a1ab67d62b211da91e5893f8a/tranche-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-12 09:21:55",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "xylar",
"github_project": "tranche",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "tranche"
}