How to use the fritzconnection.core.processor.Storage 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 / lib / fritzphonebook.py View on Github external
self.category = None
        self.uniqueid = None
        self.person = Person()
        self.telephony = Telephony()

    @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
self.argumentList = ArgumentList(self._arguments)

    @property
    def arguments(self):
        """
        Returns the action-arguments as a dict. argument-names are the
        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
github kbr / fritzconnection / fritzconnection / core / processor.py View on Github external
"""
    # case sensitive node
    allowedValue = ValueSequencer('allowed_values')

    def __init__(self):
        # 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):
github kbr / fritzconnection / fritzconnection / core / processor.py View on Github external
dictionary. Names are keys, the stateVariables objects are the
        values. Caches the dictionary once retrieved from _scpd.
        """
        if self._state_variables is None:
            self._state_variables = self._scpd.state_variables
        return self._state_variables

    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.
github kbr / fritzconnection / fritzconnection / core / processor.py View on Github external
self.UDN = None
        self.UPC = None
        self.presentationURL = None
        self.serviceList = ServiceList(self._services)
        self.deviceList = DeviceList(self.devices)

    @property
    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):
        """
github kbr / fritzconnection / fritzconnection / core / processor.py View on Github external
@processor
class Argument:
    """
    An argument with name, direction and relatedStateVariable
    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:
github kbr / fritzconnection / fritzconnection / lib / fritzcall.py View on Github external
self.Name = None
        self.Device = None
        self.Port = None
        self.Date = None
        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)