gwsumm.state.registry module

Registry for states <SummaryState>.

gwsumm.state.registry.get_state(key)[source]

Query the registry for the SummaryState registered to the given key

Parameters:
keystr

registered key of desired SummaryState. This may not match the ~SummaryState.name attribute` if the state was registered with a different key.

Returns:
stateSummaryState

the SummaryState registered with the given key

Raises:
ValueError:

if the key doesn’t map to a registered SummaryState

gwsumm.state.registry.get_states(keys={})[source]

Query the registry for a list of states (defaults to all)

Parameters:
keysset of str

the set of state keys to query in the registry

Returns:
statesdict

a dict of (key, SummaryState) pairs

Raises:
ValueError:

if any of the keys doesn’t map to a registered SummaryState

gwsumm.state.registry.register_state(state, key=None, force=False)[source]

Register a new SummaryState to the given key

Parameters:
stateSummaryState

defining Class for this state type.

keystr, optional

unique descriptive name for the SummaryState to be registered. If key=None, the :attr:`~SummaryState.key` attribute of the given state will be used.

forcebool

overwrite existing registration for this key

Raises:
ValueError

if key is already registered and force not given as True