qudi.core.ConfigOption

class qudi.core.ConfigOption(name: str | None = None, default: Any | None = None, *, missing: str | None = 'nothing', constructor: Callable | None = None, checker: Callable | None = None, converter: Callable | None = None)[source]

Bases: builtins.object

This class represents a configuration entry in the config file that is loaded before module initalisation.

__init__(name: str | None = None, default: Any | None = None, *, missing: str | None = 'nothing', constructor: Callable | None = None, checker: Callable | None = None, converter: Callable | None = None)[source]

Create a ConfigOption object.

@param name: identifier of the option in the configuration file @param default: default value for the case that the option is not set in the config file @param missing: action to take when the option is not set. ‘nothing’ does nothing, ‘warn’

logs a warning, ‘error’ logs an error and prevents the module from loading

@param constructor: constructor function for complex config option behaviour @param checker: static function that checks if value is ok @param converter: static function that forces type interpretation

Methods

__init__([name, default, missing, ...])

Create a ConfigOption object.

check(value)

If checker function set, check value.

constructor(func)

This is the decorator for declaring a constructor function for this ConfigOption.

convert(value)

If converter function set, convert value (pass-through otherwise).

copy(**kwargs)

Create a new instance of ConfigOption with copied values and update

Attributes

optional

check(value: Any) bool[source]

If checker function set, check value. Assume everything is ok otherwise.

constructor(func: Callable) Callable[source]

This is the decorator for declaring a constructor function for this ConfigOption.

@param func: constructor function for this ConfigOption @return: return the original function so this can be used as a decorator

convert(value: Any) Any[source]

If converter function set, convert value (pass-through otherwise).

copy(**kwargs)[source]

Create a new instance of ConfigOption with copied values and update

@param kwargs: extra arguments or overrides for the constructor of this class