tranche.section¶
- class tranche.section.Section(tranche, proxy, name)¶
Bases:
objectWrapper around
configparser.SectionProxyexposing tranche helpers.Provides section-scoped convenience methods while delegating all other behavior to the underlying
SectionProxy.- explain(option)¶
Explain provenance for an option in this section.
Returns a dictionary with the effective value, the source file path, and which layer provided it (“user” or “base”).
- getexpression(option, dtype=None, backend=None, allow_numpy=False)¶
Evaluate an option as a Python expression safely.
- Parameters:
option (str) – Option name within this section.
dtype (type, optional) – If provided, cast list/tuple elements or dict values.
backend ({"literal", "safe"} or None, optional) – Evaluation backend.
Nonechooses"safe"whenallow_numpyis True, otherwise"literal".allow_numpy (bool, optional) – If True and using the “safe” backend, expose limited numpy functions under
np/numpy.
- Returns:
Result of the evaluated expression, optionally cast.
- Return type:
Any
- getlist(option, dtype=None)¶
Get an option value parsed as a list.
- getnumpy(option, dtype=None, backend=None)¶
Evaluate an expression with NumPy enabled.
Shortcut equivalent to
getexpression(..., allow_numpy=True).- Parameters:
- Returns:
Result of the evaluated expression, optionally cast.
- Return type:
Any