finesse.datastore module
Finesse datastore tools.
The datastore is intended for objects that should be cached during the execution of the current Python kernel. Code typically uses this instead of the more bug-prone singleton pattern (see #260).
- finesse.datastore.getfield(key)[source]
Get value with key key.
Parameters
- keyany
The key.
Returns
- any
The value.
- finesse.datastore.hasfield(key)[source]
Determine if the datastore key key exists.
Parameters
- keyany
The singeton class to check.
Returns
- bool
True if key exists, False otherwise.
- finesse.datastore.init_singleton(cls, *args, **kwargs)[source]
Instantiate cls and return the object for the current and future calls.
Parameters
- clstype
The singeton class to retrieve. If cls has already been instantiated, the existing instance is returned and args and kwargs are ignored.
Other Parameters
- args, kwargs
Positional and keyword arguments to pass to the cls call, to use if cls is not yet instantiated.
Returns
- object
The instantiated singleton.