Example #1
0
    def __init__(self, element, base_url):
        """Initialize this Device object.

        When a Device object has been created, its Service objects are not
        fully initialized. The reason for this is that the Device object should
        be possible to inspect for relevance before services are initialized.

        Mandatory child elements of the <device> tag in the device
        configuration are added as object attributes to the newly created
        object.

        Arguments:
        element  -- element that contains device configuration
        base_url  -- the URL where the device configuration resides; used to
                    resolve relative URLs in the configuration

        """
        self._base_url = base_url
        self._services = {}
        self.element = element.find(toxpath('device', ns.device))
        self._read_services(self.element)
Example #2
0
 def _read_services(self, element):
     for service in element.findall(toxpath('serviceList/service', ns.device)):
         s = Service(self, service, self._base_url)
         self._services[s.serviceId] = s
Example #3
0
 def _add_arguments(self, element):
     for argument in element.findall(toxpath('argumentList/argument', ns.service)):
         self.arguments.append(Argument(argument))
Example #4
0
 def __getattr__(self, name):
     if not name in self.xmlattrs:
         raise NameError(name)
     return self.element.findtext(toxpath(name, self.xmlnamespace)).strip()
Example #5
0
 def _add_actions(self, element, soap_sender):
     for action in element.findall(toxpath('actionList/action', ns.service)):
         act = Action(self, action, soap_sender)
         self.actions[act.name] = act
         setattr(self, act.name, act)