heros.capabilities

Classes

Parameter

Capability

AttributeCapability

An attribute capability describes a single variable of the remote object.

EventCapability

An event capability describes the ability of a remote object to notify upon a certain event.

MethodCapability

Functions

type_to_str(→ str)

Transforms annotation given as types to strings.

Module Contents

heros.capabilities.type_to_str(annotation) str

Transforms annotation given as types to strings.

Parameters:

annotation – The typing annotation.

Returns:

Annotation as string.

class heros.capabilities.Parameter
name: str
type: str
default: str
static from_signature_parameter(p: inspect.Parameter)
has_default()
to_dict()
static from_dict(d: dict)
class heros.capabilities.Capability
name: str
flavor: ClassVar[str] = 'undefined'
to_dict()
static from_dict(d: dict)
class heros.capabilities.AttributeCapability

Bases: Capability

An attribute capability describes a single variable of the remote object. It is exposed under the name of the capability.

Parameters:
  • name – name of the capability

  • type – data type. E.g. “str”, “int”, “float”, “list”, …

  • access – Read and/or write access. “r” for read, “w” for write, and “rw” for both

flavor: ClassVar[str] = 'attribute'
type: str
access: str = 'rw'
to_dict() dict
static from_dict(d: dict) AttributeCapability
class heros.capabilities.EventCapability

Bases: Capability

An event capability describes the ability of a remote object to notify upon a certain event.

flavor: ClassVar[str] = 'event'
static from_dict(d: dict) EventCapability
class heros.capabilities.MethodCapability

Bases: Capability

flavor: ClassVar[str] = 'method'
parameters: list[Parameter] = []
return_type: str = 'None'
static from_method(m: Callable, name: str | None = None) MethodCapability
to_signature() inspect.Signature
to_dict() dict
static from_dict(d: dict) MethodCapability

Generate a method capabilities object from a defining dictionary.

Args: definition of the capability according to the standard

call_dict(*args, **kwargs) dict

This returns a dict that assigns the given parameter to the parameters of ourself. It takes care that positional and keyword arguments are handled correctly

Parameters:
  • *args – positional arguments

  • **kwargs – keyword arguments

Returns:

dict with parameter assignments

Return type:

dict