caspia.meadow package

Subpackages

Submodules

caspia.meadow.do_shortcut module

caspia.meadow.errors module

exception caspia.meadow.errors.CommunicationError(message=None, code=None, **extra)[source]

Bases: caspia.meadow.errors.MeadowError

args
code = 4
extra = {}
static from_dict(data)
static from_exception(exc)
static from_mqtt(mqtt_err_no)[source]
message = 'communication error'
to_dict()
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception caspia.meadow.errors.InvalidValueError(message=None, code=None, **extra)[source]

Bases: caspia.meadow.errors.MeadowError

args
code = 2
extra = {}
static from_dict(data)
static from_exception(exc)
message = 'invalid value'
to_dict()
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception caspia.meadow.errors.MeadowError(message=None, code=None, **extra)[source]

Bases: Exception

Represents an error within the Meadow protocol

args
code = -1
extra = {}
static from_dict(data)[source]
static from_exception(exc)[source]
message = 'unknown error'
to_dict()[source]
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception caspia.meadow.errors.NotAvailableError(message=None, code=None, **extra)[source]

Bases: caspia.meadow.errors.MeadowError

args
code = 5
extra = {}
static from_dict(data)
static from_exception(exc)
message = 'resource not available'
to_dict()
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception caspia.meadow.errors.NotReadyError(message=None, code=None, **extra)[source]

Bases: caspia.meadow.errors.MeadowError, caspia.reactive.errors.ValueNotReady

args
code = 3
extra = {}
static from_dict(data)
static from_exception(exc)
message = 'not ready'
to_dict()
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception caspia.meadow.errors.NotSupportedError(message=None, code=None, **extra)[source]

Bases: caspia.meadow.errors.MeadowError

args
code = 1
extra = {}
static from_dict(data)
static from_exception(exc)
message = 'not supported'
to_dict()
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception caspia.meadow.errors.SensorFailureError(message=None, code=None, **extra)[source]

Bases: caspia.meadow.errors.MeadowError

args
code = 101
extra = {}
static from_dict(data)
static from_exception(exc)
message = 'sensor failure'
to_dict()
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

caspia.meadow.lookup module

class caspia.meadow.lookup.ActiveNamespace(lookup, path)[source]

Bases: object

property full_path
class caspia.meadow.lookup.Lookup(create=None, prepare=None)[source]

Bases: object

This class works as a collection of known services.

add(service)[source]

Register given service within this lookup instance.

add_create_hook(func)[source]

Register a new service creator. When user requests a service from this lookup and the service is not known, the lookup tries to create it registered creators. Creator is a callable creator(service_type, service_name) -> None|Service.

add_prepare_hook(func)[source]

Register a hook (function) to be called with every new service instance added to this lookup. :param func: The function hook with signature func(new_service).

find(name, type=None)[source]

Find service with given name (and optionally type).

get(name, type=None, create=True)[source]

Get service of a given type and name. Try to create it, if create is True

namespace(path)[source]

Return object, which if used as a context manager enables use of relative names. :Example:

with lookup.namespace(‘basement’):

lookup.get(‘light’, ‘.light’) # gets service named basement.light

resolve_name(name)[source]

Resolve name with respect to active namespaces.

caspia.meadow.name module

caspia.meadow.name.match(name, pattern, *, type=None) → Optional[str][source]

Match the name against a pattern.

Parameters
  • name – the name to match

  • pattern – the name pattern

  • type – optional type to match against (overrides the one in pattern)

Returns

name on match, None otherwise

caspia.meadow.name.search(names, pattern, *, type=None)[source]

Yield all names, that matched given pattern.

caspia.meadow.name.split(name, *, strict=True) → Tuple[Optional[str], str][source]

Split name to its type and path.

Parameters
  • name – the name to split

  • strict – raise ValueError if type not specified. If False, returns None for unspecified type.

Returns

tuple (type, path)

caspia.meadow.name.update(name, **kwargs) → str[source]

Update some part of name with something else.

Parameters
  • name – the input name

  • path – new path (optional)

  • type – new type (optional)

caspia.meadow.namespace module

caspia.meadow.namespace.common_prefix(a, b)[source]
caspia.meadow.namespace.join(*args)[source]
caspia.meadow.namespace.resolve_relative(path, namespace)[source]
caspia.meadow.namespace.split(path)[source]

caspia.meadow.observers module

class caspia.meadow.observers.CharacteristicObserver(characteristic, value=None)[source]

Bases: caspia.reactive.observers.Observer, caspia.meadow.serialization.Serializable, caspia.meadow.serialization.Deserializable

static create(*args, **kwargs)
static creator(*args, **kwargs)[source]
creators = [<function CharacteristicObserver.creator>, <function FunctionObserver.creator>]
classmethod deserialize(data, context)[source]
disable()
enable()
property is_enabled
async on_error(error, **kwargs)[source]
async on_next(value, **kwargs)[source]
static register_creator(creator)
serialize()[source]

Return serialized version (most likely dict) if possible or None.

serialized_type = 'characteristic-write'
class caspia.meadow.observers.FunctionObserver[source]

Bases: caspia.reactive.observers.Observer

static create(*args, **kwargs)
static creator(*args, **kwargs)[source]
creators = [<function CharacteristicObserver.creator>, <function FunctionObserver.creator>]
disable()
enable()
property is_enabled
async on_error(error, **kwargs)[source]
async on_next(value, **kwargs)[source]
static register_creator(creator)
subscribe_error(on_error)[source]
subscribe_next(on_next)[source]

caspia.meadow.serialization module

class caspia.meadow.serialization.Deserializable[source]

Bases: object

classmethod deserialize(data, context)[source]
serialized_type = None
class caspia.meadow.serialization.Serializable[source]

Bases: object

serialize()[source]

Return serialized version (most likely dict) if possible or None.

caspia.meadow.utils module

async caspia.meadow.utils.acall(target, *args, **kwargs)[source]
caspia.meadow.utils.all_subclasses(cls)[source]
class caspia.meadow.utils.classproperty(func)[source]

Bases: object

caspia.meadow.utils.is_future(target)[source]

Module contents