Take the qualified name of a Python class, and return the physical class object.

path (str) – Dotted Python class name, e.g. <module path>.<class name>.
Class object imported from module.
Return type

Class decorator to provide a default __str__() based on the contents of __dict__.

immp.core.util.escape(raw, *chars)

Prefix special characters with backslashes, suitable for encoding in a larger string delimiting those characters.

  • raw (str) – Unsafe input string.
  • chars (str list) – Control characters to be escaped.

Escaped input string.

Return type


immp.core.util.unescape(raw, *chars)

Inverse of escape(), remove backslashes escaping special characters.

  • raw (str) – Escaped input string.
  • chars (str list) – Control characters to be unescaped.

Raw unescaped string.

Return type


class immp.core.util.Watchable(watch)

Bases: object

Container mixin to trigger a callback when its contents are changed.

classmethod unwrap(obj)

Recursively replace Watchable subclasses with their native equivalents.

obj – Container type, or any value.
Unwrapped container, or the original value.
classmethod watch(*methods)

Class decorator for mixin users, to wrap methods that modify the underlying container, and should therefore trigger the callback when invoked.

methods (str list) – List of method names to individually wrap.
class immp.core.util.WatchedDict(watch, initial, **kwargs)

Bases: dict, immp.core.util.Watchable

Watchable-enabled dict subclass. Lists or dictionaries added as items in this container will be wrapped automatically.

clear() → None. Remove all items from D.
pop(k[, d]) → v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised

popitem() → (k, v), remove and return some (key, value) pair as a

2-tuple; but raise KeyError if D is empty.

setdefault(k[, d]) → D.get(k,d), also set D[k]=d if k not in D
class immp.core.util.WatchedList(watch, initial)

Bases: list, immp.core.util.Watchable

Watchable-enabled list subclass. Lists or dictionaries added as items in this container will be wrapped automatically.

clear() → None -- remove all items from L
pop([index]) → item -- remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove(value) → None -- remove first occurrence of value.

Raises ValueError if the value is not present.


L.reverse() – reverse IN PLACE

sort(key=None, reverse=False) → None -- stable sort *IN PLACE*
class immp.core.util.ConfigProperty(cls=None, key=None)

Bases: object

Data descriptor to present config from Openable instances using the actual objects stored in a Host.

class immp.core.util.IDGen

Bases: object

Generator of generic timestamp-based identifiers.

IDs are guaranteed unique for the lifetime of the application – two successive calls will yield two different identifiers.

class immp.core.util.LocalFilter(name='')

Bases: logging.Filter

Logging filter that restricts capture to loggers within the immp namespace.

class immp.core.util.OpenState

Bases: enum.Enum

Readiness status for instances of Openable.


Not currently in use, and won’t be started by the host.


Hasn’t been started yet.


Currently starting up (during Openable.start()).


Currently running.


Currently closing down (during Openable.stop()).


Exception occurred during starting or stopping phases.

class immp.core.util.Configurable(name, config, host)

Bases: object

Superclass for objects managed by a Host and created using configuration.


.Schema – Structure of the config expected by this configurable. If not customised by the subclass, it defaults to dict (that is, any dict structure is valid).

It may also be set to None, to declare that no configuration is accepted.


str – User-provided, unique name of the hook, used for config references.


dict – Reference to the user-provided configuration. Assigning to this field will validate the data against the class schema, which may raise exceptions on failure as defined by Schema.validate().


.Host – Controlling host instance, providing access to plugs.

class immp.core.util.Openable

Bases: object

Abstract class to provide open and close hooks. Subclasses should implement start() and stop(), whilst users should make use of open() and close().


.OpenState – Current status of this resource.


Open this resource ready for use. Does nothing if already open, but raises RuntimeError if currently changing state.


Perform any operations needed to open this resource.


Close this resource after it’s used. Does nothing if already closed, but raises RuntimeError if currently changing state.


Perform any operations needed to close this resource.


Prevent this openable from being run by the host.


Restore normal operation of this openable.

class immp.core.util.HTTPOpenable(name, config, host)

Bases: immp.core.util.Openable

Template openable including a aiohttp.ClientSession instance for networking.


aiohttp.ClientSession – Managed session object.