KeyValueRegistry

class jwst.associations.lib.keyvalue_registry.KeyValueRegistry(items=None, default=None)[source]

Bases: UserDict

Provide a dict-like registry.

Differences from just a dict:

  • Can be given single item or a 2-tuple. If an item, attempts to read the __name__ attribute and use that as the key.

  • If None is given as a key, a default key can be specified.

  • Instances can be used as decorators.

Parameters:
itemsobject or (str, object) or dict

Initializing items.

defaultstr or object

The default to use when key is None.

Methods Summary

__call__(item)

Add item by calling instance.

update(item)

Add item to registry.

Methods Documentation

__call__(item)[source]

Add item by calling instance.

This allows an instance to be used as a decorator.

Parameters:
itemobject or (str, object) or dict

Item used for decoration.

Returns:
itemobject or (str, object) or dict

The item used to update self.

update(item)[source]

Add item to registry.