asphalt.core.util¶
-
asphalt.core.util.resolve_reference(ref)¶ Return the object pointed to by
ref.If
refis not a string or does not contain:, it is returned as is.References must be in the form <modulename>:<varname> where <modulename> is the fully qualified module name and varname is the path to the variable inside that module.
For example, “concurrent.futures:Future” would give you the
Futureclass.Raises: LookupError – if the reference could not be resolved
-
asphalt.core.util.qualified_name(obj)¶ Return the qualified name (e.g. package.module.Type) for the given object.
Return type: str
-
asphalt.core.util.merge_config(original, overrides)¶ Return a copy of the
originalconfiguration dictionary, with overrides fromoverridesapplied.This similar to what
dict.update()does, but when a dictionary is about to be replaced with another dictionary, it instead merges the contents.If a key in
overridesis a dotted path (ie.foo.bar.baz: value), it is assumed to be a shorthand forfoo: {bar: {baz: value}}.Parameters: Return type: Returns: the merge result
-
class
asphalt.core.util.PluginContainer(namespace, base_class=None)¶ A convenience class for loading and instantiating plugins through the use of entry points.
Parameters: -
all()¶ Load all entry points (if not already loaded) in this namespace and return the resulting objects as a list.
Return type: List[Any]
-
create_object(type, **constructor_kwargs)¶ Instantiate a plugin.
The entry points in this namespace must point to subclasses of the
base_classparameter passed to this container.Parameters: Returns: the plugin instance
-
resolve(obj)¶ Resolve a reference to an entry point or a variable in a module.
If
objis amodule:varnamereference to an object,resolve_reference()is used to resolve it. If it is a string of any other kind, the named entry point is loaded from this container’s namespace. Otherwise,objis returned as is.Parameters: obj – an entry point identifier, an object reference or an arbitrary object Returns: the loaded entry point, resolved object or the unchanged input value Raises: LookupError – if objwas a string but the named entry point was not found
-