ClassRegistry¶
-
class
tfsnippet.utils.
ClassRegistry
(ignore_case=False)¶ Bases:
tfsnippet.utils.registry.BaseRegistry
A subclass of
BaseRegistry
, dedicated for classes.Usage:
Class MyClass(object): def __init__(self, value, message): ... registry = ClassRegistry() registry.register('MyClass', MyClass) obj = registry.create_object('MyClass', 123, message='message')
Attributes Summary
ignore_case
Whether or not to ignore the case? Methods Summary
construct
(name, *args, **kwargs)Construct an object according to class name and arguments. get
(name)Get an object. register
(name, obj)Register an object. Attributes Documentation
-
ignore_case
¶ Whether or not to ignore the case?
Methods Documentation
-
construct
(name, *args, **kwargs)¶ Construct an object according to class name and arguments.
Parameters: - name (str) – Name of the class.
- *args – Arguments passed to the class constructor.
- **kwargs – Named arguments passed to the class constructor.
Returns: The constructed object.
Raises: KeyError
– If name is not registered.
-