lofar_parameterset.parameterset module
Drop-in replacement for LCS/pyparameterset, which in turn wraps LCS/Common/src/ParameterSet.cc.
This replacement provides a narrow implementation. It writes compatible parsets, but cannot read all the syntax variants supported by pyparameterset. Those variants are thus deprecated.
Not supported are:
Vector expansion, f.e. foo=[‘bar’*4] and foo=[1..5]
Value interpretations beyond bool, int, float, and string
Multi-line values
String escaping beyond either “ or ‘ in the string
Modeling of ParameterValue as a separate class
Case-insensitivity of keys
Tracking of unused keys
- class lofar_parameterset.parameterset.parameterset(content: dict = {})[source]
Bases:
dict- _getVector(key: str) list[str][source]
Return the values of a vector, encoded as [a, b, c] or with the values quoted.
- _toBool(value: str | bool) bool[source]
Convert a string to boolean. Case is ignored. “true”, “t”, “yes”, “y”, and “1” evaluate to True. “false”, “f”, “no”, “n”, and “0” evaluate to False. Other values raise a ValueError.
- adoptArgv(argv: list[str])[source]
Add keys as provided on the command line in the form of “key=value”.
- fullModuleName(module: str)[source]
Searches for a key ending in the given ‘shortkey’ and returns it full name. e.g: a.b.c.d.param=xxxx –> fullModuleName(d) –> a.b.c.d e.g: a.b.c.d.param=xxxx –> fullModuleName(b.c) –> a.b.c e.g: a.b.c.d.param=xxxx –> fullModuleName(d.param)–>
- getBool(key: str, default: bool | None = None) bool[source]
Return a value as boolean, with the given default if it is not found. If no default is provided either, a KeyError is thrown. A value is considered True if it’s “true”, “t”, “yes”, “y”, or “1”. A value is considered False if it’s “false”, “f”, “no”, “n”, or “0”. Any other value raises a ValueError. Case of the value is ignored.
- getBoolVector(key: str, expandable: bool = False) list[bool][source]
Return a parset value as a boolean list.
expandable: deprecated, will be ignored.
- getDouble(key: str, default: float | None = None) float[source]
Return a value as float, with the given default if it is not found. If no default is provided either, a KeyError is thrown.
- getDoubleVector(key: str, expandable: bool = False) list[float][source]
Return a parset value as a float list.
expandable: deprecated, will be ignored.
- getInt(key: str, default: int | None = None) int[source]
Return a value as integer, with the given default if it is not found. If no default is provided either, a KeyError is thrown.
- getIntVector(key: str, expandable: bool = False) list[int][source]
Return a parset value as an integer list.
expandable: deprecated, will be ignored.
- getString(key: str, default: str | None = None) str[source]
Return a value as string, with the given default if it is not found. If no default is provided either, a KeyError is thrown.
- getStringVector(key: str, expandable: bool = False) list[str][source]
Return a parset value as a string list.
expandable: deprecated, will be ignored.
- makeSubset(baseKey: str, prefix: str = '') parameterset[source]
Creates a Subset from the current ParameterSetImpl containing all the parameters that start with the given baseKey. The baseKey is cut off from the Keynames in the created subset, the optional prefix is put before the keynames.