jacinle.utils.registry#

Classes

Functions

register_event(registry_name, entry, value, ...)

subclass_registry_point(wrapped)

trigger_event(registry_name, entry, *args, ...)

Class CallbackRegistry

class CallbackRegistry[source]#

Bases: Registry

A callable manager utils.

If there exists a super callback, it will block all callbacks. A super callback will receive the called name as its first argument.

Then the dispatcher will try to call the callback by name. If such name does not exists, a fallback callback will be called.

The fallback callback will also receive the called name as its first argument.

Example

>>> registry = CallbackRegistry()
>>> callback_func = print
>>> registry.register('name', callback_func)  # register a callback.
>>> registry.dispatch('name', 'arg1', 'arg2', kwarg1='kwarg1')  # dispatch.
__init__()[source]#
__new__(**kwargs)#
dispatch(name, *args, **kwargs)[source]#
dispatch_direct(name, *args, **kwargs)[source]#

Dispatch by name, ignoring the super callback.

has(entry)#
items()#
keys()#
lookup(entry, fallback=True, default=None)#
register(entry, value)#
set_fallback(value)#
set_fallback_callback(callback)[source]#
set_super_callback(callback)[source]#
unregister(entry)#
property fallback#
property fallback_callback#
property super_callback#

Class DefaultRegistry

class DefaultRegistry[source]#

Bases: Registry

__init__()#
__new__(**kwargs)#
has(entry)#
items()#
keys()#
lookup(entry, fallback=False, default=None)[source]#
register(entry, value)#
set_fallback(value)#
unregister(entry)#
property fallback#

Class EventRegistry

class EventRegistry[source]#

Bases: Registry

__init__()#
__new__(**kwargs)#
has(entry)#
items()#
keys()#
lookup(entry, key=None, priority=DEF_PRIORITY, default=None)[source]#
register(entry, callback, priority=DEF_PRIORITY, subkey=None)[source]#
set_fallback(value)#
trigger(entry, *args, **kwargs)[source]#
trigger_args(entry, args, kwargs)[source]#
unregister(entry, key=None, priority=DEF_PRIORITY)[source]#
DEF_PRIORITY = 10#
property fallback#

Class EventRegistryGroup

class EventRegistryGroup[source]#

Bases: RegistryGroup

__init__()#
__new__(**kwargs)#
lookup(registry_name, entry, key=None, **kwargs)[source]#
register(registry_name, entry, value, **kwargs)#
trigger(registry_name, entry, *args, **kwargs)[source]#

Class LockRegistry

class LockRegistry[source]#

Bases: DefaultRegistry

__init__()#
__new__(**kwargs)#
has(entry)#
items()#
keys()#
lookup(entry, fallback=False, default=None)#
register(entry, value)#
set_fallback(value)#
synchronized(entry, activate=True)[source]#
unregister(entry)#
property fallback#

Class Registry

class Registry[source]#

Bases: object

__init__()[source]#
__new__(**kwargs)#
has(entry)[source]#
items()[source]#
keys()[source]#
lookup(entry, fallback=True, default=None)[source]#
register(entry, value)[source]#
set_fallback(value)[source]#
unregister(entry)[source]#
property fallback#

Class RegistryGroup

class RegistryGroup[source]#

Bases: object

__init__()[source]#
__new__(**kwargs)#
lookup(registry_name, entry, fallback=True, default=None)[source]#
register(registry_name, entry, value, **kwargs)[source]#

Class SimpleEventRegistry

class SimpleEventRegistry[source]#

Bases: object

__init__(allowed_events=None)[source]#
__new__(**kwargs)#
register(event, callback)[source]#
trigger(event, *args, **kwargs)[source]#
property allowed_events#

Functions

register_event(registry_name, entry, value, **kwargs)#
subclass_registry_point(wrapped)[source]#
trigger_event(registry_name, entry, *args, **kwargs)#