How to use the fritzconnection.core.processor.InstanceAttributeFactory function in fritzconnection

To help you get started, we’ve selected a few fritzconnection examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kbr / fritzconnection / fritzconnection / core / processor.py View on Github external
attributes.
    """
    def __init__(self):
        # attributes are case sensitive node names
        self.name = None
        self.direction = None
        self.relatedStateVariable = None


@processor
class ArgumentList(Storage):
    """
    Collects the arguments for an action.
    """
    # case sensitive node
    argument = InstanceAttributeFactory(Argument)


@processor
class Action:
    """
    Every Action has a name and a list of arguments.
    """
    def __init__(self):
        self._arguments = list()
        self._arguments_storage = None
        # attributes are case sensitive node names:
        self.name = None
        self.argumentList = ArgumentList(self._arguments)

    @property
    def arguments(self):
github kbr / fritzconnection / fritzconnection / core / processor.py View on Github external
def load_scpd(self, address, port, timeout=None, session=None):
        """Loads the scpd data"""
        url = f'{address}:{port}{self.SCPDURL}'
        root = get_xml_root(url, timeout=timeout, session=session)
        self._scpd = Scpd(root)


@processor
class ServiceList(Storage):
    """
    Collection of Service instances for a device.
    The service instances are stored in the device.services attribute.
    """
    # case sensitive node
    service = InstanceAttributeFactory(Service)


@processor
class Device:
    """
    Storage for devices attributes and device subnodes.
    Subnodes are the serviceList and the deviceList.
    The services provided by a device are collected in services.
    Subdevices are collected in devices.
    All instance attributes are public for read only use.
    """
    def __init__(self):
        self._services = list()
        self.devices = list()
        # attributes are case sensitive node names:
        self.deviceType = None
github kbr / fritzconnection / fritzconnection / lib / fritzcall.py View on Github external
self.Duration = None
        self.Count = None

    def __str__(self):
        number = self.Called if self.type == 3 else self.Caller
        duration = self.Duration if self.type != 2 else "-"
        if not number:
            number = "-"
        return f'{self.Type:>6}   {number:24}{self.Date:>18}{duration:>12}'


class CallCollection(Storage):
    """
    Container for a sequence of Call instances.
    """
    Call = InstanceAttributeFactory(Call)

    def __init__(self, root):
        self.timestamp = None
        self.calls = list()
        super().__init__(self.calls)
        process_node(self, root)

    def __iter__(self):
        return iter(self.calls)
github kbr / fritzconnection / fritzconnection / lib / fritzphonebook.py View on Github external
    @property
    def name(self):
        return self.person.realName

    @property
    def numbers(self):
        return self.telephony.numbers


@processor
class Phonebook(Storage):
    """
    Represents a phonebook with a timestamp indicating the last
    modification and a list of Contact instances.
    """
    contact = InstanceAttributeFactory(Contact)

    def __init__(self):
        self.timestamp = None
        self.contacts = list()
        super().__init__(self.contacts)
github kbr / fritzconnection / fritzconnection / core / processor.py View on Github external
def services(self):
        services = {service.name: service for service in self._services}
        for device in self.devices:
            services.update(device.services)
        return services


@processor
class DeviceList(Storage):
    """
    Collection of sub-devices of a device.
    The Device instances are stored in the device.devices attribute of
    the parent device.
    """
    # case sensitive node
    device = InstanceAttributeFactory(Device)


class Description:
    """
    Root class for a given description information as the content from
    the files igddesc.xml or tr64desc.xml.
    """
    def __init__(self, root):
        """
        Starts data-processing. 'root' must be an xml.Element object as
        returned from 'utils.get_xml_root'.
        """
        # attributes are case sensitive node names:
        self.device = Device()
        self.specVersion = SpecVersion()
        self.systemVersion = SystemVersion()
github kbr / fritzconnection / fritzconnection / core / processor.py View on Github external
# attributes are case sensitive node names:
        self.name = None
        self.dataType = None
        self.defaultValue = None
        self.allowed_values = list()
        self.allowedValueList = self
        self.allowedValueRange = ValueRange()


@processor
class ServiceStateTable(Storage):
    """
    Collection of stateVariables.
    """
    # case sensitive node
    stateVariable = InstanceAttributeFactory(StateVariable)


class Scpd:
    """
    Provides informations about the Service Control Point Definitions
    for every Service. Every Service has one instance of this class for
    accessing the description of it's own actions and the according
    parameters.
    Root class for processing the content of an scpd-file.
    """
    def __init__(self, root):
        """
        Starts interpreting the scpd-data. 'root' must be an xml.Element
        objects as returned from 'utils.get_xml_root'.
        """
        self._actions = list()
github kbr / fritzconnection / fritzconnection / core / processor.py View on Github external
keys and the argument objects are the values. The dictionary
        gets cached.
        """
        if not self._arguments_storage:
            self._arguments_storage = {arg.name: arg for arg in self._arguments}
        return self._arguments_storage


@processor
class ActionList(Storage):
    """
    Collection of actions of a service.
    The Action instances are stored in the Scpd.actions attribute.
    """
    # case sensitive node
    action = InstanceAttributeFactory(Action)


@processor
class ValueRange:

    def __init__(self):
        # attributes are case sensitive node names:
        self.minimum = None
        self.maximum = None
        self.step = None


@processor
class StateVariable:
    """
    Represents a stateVariable with the attributes name, dataType,