qt_binder.type_registry
¶
-
class
qt_binder.type_registry.
TypeRegistry
[source]¶ Bases:
object
Register objects for types.
Each type maintains a stack of registered objects that can be pushed and popped.
-
push
(typ, obj)[source]¶ Push an object onto the stack for the given type.
Parameters: - typ (type or '__module__:__name__' string for a type) – The type the object corresponds to.
- obj (object) – The object to register.
-
push_abc
(typ, obj)[source]¶ Push an object onto the stack for the given ABC.
Parameters: - typ (abc.ABCMeta) – The ABC the object corresponds to.
- obj (object) – The object to register.
-
pop
(typ)[source]¶ Pop a registered object for the given type.
Parameters: typ (type or '__module__:__name__' string for a type) – The type to look up. Returns: obj (object) – The last registered object for the type. Raises: KeyError
if the type is not registered.
-
lookup
(instance)[source]¶ Look up the registered object for the given instance.
Parameters: instance (object) – An instance of a possibly registered type. Returns: obj (object) – The registered object for the type of the instance, one of the type’s superclasses, or else one of the ABCs the type implements. Raises: KeyError
if the instance’s type has not been registered.
-
lookup_by_type
(typ)[source]¶ Look up the registered object for a type.
typ : type
Returns: obj (object) – The registered object for the type, one of its superclasses, or else one of the ABCs it implements. Raises: KeyError
if the type has not been registered.
-
lookup_all
(instance)[source]¶ Look up all the registered objects for the given instance.
Parameters: instance (object) – An instance of a possibly registered type. Returns: objs (list of objects) – The list of registered objects for the instance. If the given instance is not registered, its superclasses are searched. If none of the superclasses are registered, search the possible ABCs. Raises: KeyError
if the instance’s type has not been registered.
-
lookup_all_by_type
(typ)[source]¶ Look up all the registered objects for a type.
- typ : type
- The type to look up.
Returns: objs (list of objects) – The list of registered objects for the type. If the given type is not registered, its superclasses are searched. If none of the superclasses are registered, search the possible ABCs. Raises: KeyError
if the type has not been registered.
-
-
class
qt_binder.type_registry.
LazyRegistry
[source]¶ Bases:
qt_binder.type_registry.TypeRegistry
A type registry that will lazily import the registered objects.
Register ‘__module__:__name__’ strings for the lazily imported objects. These will only be imported when the matching type is looked up. The module name must be a fully-qualified absolute name with all of the parent packages specified.