Ejemplo n.º 1
0
    def parse_xml_node(self, node):
        '''Parse an xml.dom Node object representing a service port connector into
        this object.

        '''
        self.connector_id = node.getAttributeNS(RTS_NS, 'connectorId')
        self.name = node.getAttributeNS(RTS_NS, 'name')
        if node.hasAttributeNS(RTS_NS, 'transMethod'):
            self.trans_method = node.getAttributeNS(RTS_NS,
                                                         'transMethod')
        else:
            self.trans_method = ''
        self.comment = node.getAttributeNS(RTS_EXT_NS, 'comment')
        if node.hasAttributeNS(RTS_EXT_NS, 'visible'):
            visible = node.getAttributeNS(RTS_EXT_NS, 'visible')
            if visible == 'true' or visible == '1':
                self.visible = True
            else:
                self.visible = False

        if node.getElementsByTagNameNS(RTS_NS, 'sourceServicePort').length != 1:
            raise InvalidServicePortConnectorNodeError
        self.source_service_port = TargetPort().parse_xml_node(\
                node.getElementsByTagNameNS(RTS_NS, 'sourceServicePort')[0])
        if node.getElementsByTagNameNS(RTS_NS, 'targetServicePort').length != 1:
            raise InvalidServicePortConnectorNodeError
        self.target_service_port = TargetPort().parse_xml_node(\
                node.getElementsByTagNameNS(RTS_NS, 'targetServicePort')[0])
        for c in get_direct_child_elements_xml(node, prefix=RTS_EXT_NS,
                                               local_name='Properties'):
            name, value = parse_properties_xml(c)
            self._properties[name] = value
        return self
Ejemplo n.º 2
0
    def parse_xml_node(self, node):
        '''Parse an xml.dom Node object representing a service port connector into
        this object.

        '''
        self.connector_id = node.getAttributeNS(RTS_NS, 'connectorId')
        self.name = node.getAttributeNS(RTS_NS, 'name')
        if node.hasAttributeNS(RTS_NS, 'transMethod'):
            self.trans_method = node.getAttributeNS(RTS_NS,
                                                         'transMethod')
        else:
            self.trans_method = ''
        self.comment = node.getAttributeNS(RTS_EXT_NS, 'comment')
        if node.hasAttributeNS(RTS_EXT_NS, 'visible'):
            visible = node.getAttributeNS(RTS_EXT_NS, 'visible')
            if visible == 'true' or visible == '1':
                self.visible = True
            else:
                self.visible = False

        if node.getElementsByTagNameNS(RTS_NS, 'sourceServicePort').length != 1:
            raise InvalidServicePortConnectorNodeError
        self.source_service_port = TargetPort().parse_xml_node(\
                node.getElementsByTagNameNS(RTS_NS, 'sourceServicePort')[0])
        if node.getElementsByTagNameNS(RTS_NS, 'targetServicePort').length != 1:
            raise InvalidServicePortConnectorNodeError
        self.target_service_port = TargetPort().parse_xml_node(\
                node.getElementsByTagNameNS(RTS_NS, 'targetServicePort')[0])
        for c in get_direct_child_elements_xml(node, prefix=RTS_EXT_NS,
                                               local_name='Properties'):
            name, value = parse_properties_xml(c)
            self._properties[name] = value
        return self
Ejemplo n.º 3
0
    def parse_xml_node(self, node):
        '''Parse an xml.dom Node object representing a component into this
        object.

        >>> c = Component()
        '''
        self._reset()
        # Get the attributes
        self.id = node.getAttributeNS(RTS_NS, 'id')
        self.path_uri = node.getAttributeNS(RTS_NS, 'pathUri')
        if node.hasAttributeNS(RTS_NS, 'activeConfigurationSet'):
            self.active_configuration_set = node.getAttributeNS(
                RTS_NS, 'activeConfigurationSet')
        else:
            self.active_configuration_set = ''
        self.instance_name = node.getAttributeNS(RTS_NS, 'instanceName')
        self.compositeType = comp_type.from_string(
            node.getAttributeNS(RTS_NS, 'compositeType'))
        required = node.getAttributeNS(RTS_NS, 'isRequired')
        if required == 'true' or required == '1':
            self.is_required = True
        else:
            self.is_required = False
        self.comment = node.getAttributeNS(RTS_EXT_NS, 'comment')
        if node.hasAttributeNS(RTS_EXT_NS, 'visible'):
            visible = node.getAttributeNS(RTS_EXT_NS, 'visible')
            if visible.lower() == 'true' or visible == '1':
                self.visible = True
            else:
                self.visible = False

        # Get the children
        for c in node.getElementsByTagNameNS(RTS_NS, 'DataPorts'):
            self._data_ports.append(DataPort().parse_xml_node(c))
        for c in node.getElementsByTagNameNS(RTS_NS, 'ServicePorts'):
            self._service_ports.append(ServicePort().parse_xml_node(c))
        for c in node.getElementsByTagNameNS(RTS_NS, 'ConfigurationSets'):
            self._config_sets.append(ConfigurationSet().parse_xml_node(c))
        for c in node.getElementsByTagNameNS(RTS_NS, 'ExecutionContexts'):
            self._exec_contexts.append(ExecutionContext().parse_xml_node(c))
        for c in node.getElementsByTagNameNS(RTS_NS, 'Participants'):
            self._participants.append(Participant().parse_xml_node(c))
        # Extended profile children
        c = node.getElementsByTagNameNS(RTS_EXT_NS, 'Location')
        if c.length > 0:
            if c.length > 1:
                raise InvalidRtsProfileNodeError('Location')
            self._location = Location().parse_xml_node(c[0])
        for c in get_direct_child_elements_xml(node,
                                               prefix=RTS_EXT_NS,
                                               local_name='Properties'):
            name, value = parse_properties_xml(c)
            self._properties[name] = value

        return self
Ejemplo n.º 4
0
    def parse_xml_node(self, node):
        '''Parse an xml.dom Node object representing a component into this
        object.

        >>> c = Component()
        '''
        self._reset()
        # Get the attributes
        self.id = node.getAttributeNS(RTS_NS, 'id')
        self.path_uri = node.getAttributeNS(RTS_NS, 'pathUri')
        if node.hasAttributeNS(RTS_NS, 'activeConfigurationSet'):
            self.active_configuration_set = node.getAttributeNS(RTS_NS,
                    'activeConfigurationSet')
        else:
            self.active_configuration_set = ''
        self.instance_name = node.getAttributeNS(RTS_NS, 'instanceName')
        self.compositeType = comp_type.from_string(node.getAttributeNS(RTS_NS,
                'compositeType'))
        required = node.getAttributeNS(RTS_NS, 'isRequired')
        if required == 'true' or required == '1':
            self.is_required = True
        else:
            self.is_required = False
        self.comment = node.getAttributeNS(RTS_EXT_NS, 'comment')
        if node.hasAttributeNS(RTS_EXT_NS, 'visible'):
            visible = node.getAttributeNS(RTS_EXT_NS, 'visible')
            if visible.lower() == 'true' or visible == '1':
                self.visible = True
            else:
                self.visible = False

        # Get the children
        for c in node.getElementsByTagNameNS(RTS_NS, 'DataPorts'):
            self._data_ports.append(DataPort().parse_xml_node(c))
        for c in node.getElementsByTagNameNS(RTS_NS, 'ServicePorts'):
            self._service_ports.append(ServicePort().parse_xml_node(c))
        for c in node.getElementsByTagNameNS(RTS_NS, 'ConfigurationSets'):
            self._config_sets.append(ConfigurationSet().parse_xml_node(c))
        for c in node.getElementsByTagNameNS(RTS_NS, 'ExecutionContexts'):
            self._exec_contexts.append(ExecutionContext().parse_xml_node(c))
        for c in node.getElementsByTagNameNS(RTS_NS, 'Participants'):
            self._participants.append(Participant().parse_xml_node(c))
        # Extended profile children
        c = node.getElementsByTagNameNS(RTS_EXT_NS, 'Location')
        if c.length > 0:
            if c.length > 1:
                raise InvalidRtsProfileNodeError('Location')
            self._location = Location().parse_xml_node(c[0])
        for c in get_direct_child_elements_xml(node, prefix=RTS_EXT_NS,
                                               local_name='Properties'):
            name, value = parse_properties_xml(c)
            self._properties[name] = value

        return self
Ejemplo n.º 5
0
    def parse_xml_node(self, node):
        '''Parse an xml.dom Node object representing a condition into this
        object.

        '''
        self.sequence = int(node.getAttributeNS(RTS_NS, 'sequence'))
        c = node.getElementsByTagNameNS(RTS_NS, 'TargetComponent')
        if c.length != 1:
            raise InvalidParticipantNodeError
        self.target_component = TargetExecutionContext().parse_xml_node(c[0])
        for c in get_direct_child_elements_xml(node, prefix=RTS_EXT_NS,
                                               local_name='Properties'):
            name, value = parse_properties_xml(c)
            self._properties[name] = value
        return self
Ejemplo n.º 6
0
    def parse_xml_node(self, node):
        '''Parse an xml.dom Node object representing a service port into this
        object.

        '''

        self.name = node.getAttributeNS(RTS_NS, 'name')
        self.comment = node.getAttributeNS(RTS_EXT_NS, 'comment')
        if node.hasAttributeNS(RTS_EXT_NS, 'visible'):
            visible = node.getAttributeNS(RTS_EXT_NS, 'visible')
            if visible.lower() == 'true' or visible == '1':
                self.visible = True
            else:
                self.visible = False
        for c in get_direct_child_elements_xml(node, prefix=RTS_EXT_NS,
                                               local_name='Properties'):
            name, value = parse_properties_xml(c)
            self._properties[name] = value
        return self
Ejemplo n.º 7
0
    def parse_xml_node(self, node):
        '''Parse an xml.dom Node object representing an execution context into
        this object.

        '''
        self.id = node.getAttributeNS(RTS_NS, 'id')
        self.kind = node.getAttributeNS(RTS_NS, 'kind')
        if node.hasAttributeNS(RTS_NS, 'rate'):
            self.rate = float(node.getAttributeNS(RTS_NS, 'rate'))
        else:
            self.rate = 0.0
        self._participants = []
        for c in node.getElementsByTagNameNS(RTS_NS, 'Participants'):
            self._participants.append(TargetComponent().parse_xml_node(c))
        for c in get_direct_child_elements_xml(node, prefix=RTS_EXT_NS,
                                               local_name='Properties'):
            name, value = parse_properties_xml(c)
            self._properties[name] = value
        return self
Ejemplo n.º 8
0
    def parse_xml_node(self, node):
        '''Parse an xml.dom Node object representing a service port into this
        object.

        '''

        self.name = node.getAttributeNS(RTS_NS, 'name')
        self.comment = node.getAttributeNS(RTS_EXT_NS, 'comment')
        if node.hasAttributeNS(RTS_EXT_NS, 'visible'):
            visible = node.getAttributeNS(RTS_EXT_NS, 'visible')
            if visible.lower() == 'true' or visible == '1':
                self.visible = True
            else:
                self.visible = False
        for c in get_direct_child_elements_xml(node,
                                               prefix=RTS_EXT_NS,
                                               local_name='Properties'):
            name, value = parse_properties_xml(c)
            self._properties[name] = value
        return self
Ejemplo n.º 9
0
    def parse_xml_node(self, node):
        '''Parse an xml.dom Node object representing an execution context into
        this object.

        '''
        self.id = node.getAttributeNS(RTS_NS, 'id')
        self.kind = node.getAttributeNS(RTS_NS, 'kind')
        if node.hasAttributeNS(RTS_NS, 'rate'):
            self.rate = float(node.getAttributeNS(RTS_NS, 'rate'))
        else:
            self.rate = 0.0
        self._participants = []
        for c in node.getElementsByTagNameNS(RTS_NS, 'Participants'):
            self._participants.append(TargetComponent().parse_xml_node(c))
        for c in get_direct_child_elements_xml(node,
                                               prefix=RTS_EXT_NS,
                                               local_name='Properties'):
            name, value = parse_properties_xml(c)
            self._properties[name] = value
        return self
Ejemplo n.º 10
0
    def parse_xml_node(self, node):
        '''Parse an xml.dom Node object representing a data connector into this
        object.

        '''
        self.connector_id = node.getAttributeNS(RTS_NS, 'connectorId')
        self.name = node.getAttributeNS(RTS_NS, 'name')
        self.data_type = node.getAttributeNS(RTS_NS, 'dataType')
        self.interface_type = node.getAttributeNS(RTS_NS, 'interfaceType')
        self.data_flow_type = node.getAttributeNS(RTS_NS, 'dataflowType')
        if node.hasAttributeNS(RTS_NS, 'subscriptionType'):
            self.subscription_type = node.getAttributeNS(RTS_NS,
                                                         'subscriptionType')
        else:
            self.subscription_type = ''
        if node.hasAttributeNS(RTS_NS, 'pushInterval'):
            self.push_interval = float(node.getAttributeNS(RTS_NS,
                                                           'pushInterval'))
        else:
            self.push_interval = 0.0
        self.comment = node.getAttributeNS(RTS_EXT_NS, 'comment')
        if node.hasAttributeNS(RTS_EXT_NS, 'visible'):
            visible = node.getAttributeNS(RTS_EXT_NS, 'visible')
            if visible == 'true' or visible == '1':
                self.visible = True
            else:
                self.visible = False

        if node.getElementsByTagNameNS(RTS_NS, 'sourceDataPort').length != 1:
            raise InvalidDataPortConnectorNodeError
        self.source_data_port = TargetPort().parse_xml_node(\
                node.getElementsByTagNameNS(RTS_NS, 'sourceDataPort')[0])
        if node.getElementsByTagNameNS(RTS_NS, 'targetDataPort').length != 1:
            raise InvalidDataPortConnectorNodeError
        self.target_data_port = TargetPort().parse_xml_node(\
                node.getElementsByTagNameNS(RTS_NS, 'targetDataPort')[0])
        for c in get_direct_child_elements_xml(node, prefix=RTS_EXT_NS,
                                               local_name='Properties'):
            name, value = parse_properties_xml(c)
            self._properties[name] = value
        return self
Ejemplo n.º 11
0
    def parse_xml_node(self, node):
        '''Parse an xml.dom Node object representing a data connector into this
        object.

        '''
        self.connector_id = node.getAttributeNS(RTS_NS, 'connectorId')
        self.name = node.getAttributeNS(RTS_NS, 'name')
        self.data_type = node.getAttributeNS(RTS_NS, 'dataType')
        self.interface_type = node.getAttributeNS(RTS_NS, 'interfaceType')
        self.data_flow_type = node.getAttributeNS(RTS_NS, 'dataflowType')
        if node.hasAttributeNS(RTS_NS, 'subscriptionType'):
            self.subscription_type = node.getAttributeNS(RTS_NS,
                                                         'subscriptionType')
        else:
            self.subscription_type = ''
        if node.hasAttributeNS(RTS_NS, 'pushInterval'):
            self.push_interval = float(node.getAttributeNS(RTS_NS,
                                                           'pushInterval'))
        else:
            self.push_interval = 0.0
        self.comment = node.getAttributeNS(RTS_EXT_NS, 'comment')
        if node.hasAttributeNS(RTS_EXT_NS, 'visible'):
            visible = node.getAttributeNS(RTS_EXT_NS, 'visible')
            if visible == 'true' or visible == '1':
                self.visible = True
            else:
                self.visible = False

        if node.getElementsByTagNameNS(RTS_NS, 'sourceDataPort').length != 1:
            raise InvalidDataPortConnectorNodeError
        self.source_data_port = TargetPort().parse_xml_node(\
                node.getElementsByTagNameNS(RTS_NS, 'sourceDataPort')[0])
        if node.getElementsByTagNameNS(RTS_NS, 'targetDataPort').length != 1:
            raise InvalidDataPortConnectorNodeError
        self.target_data_port = TargetPort().parse_xml_node(\
                node.getElementsByTagNameNS(RTS_NS, 'targetDataPort')[0])
        for c in get_direct_child_elements_xml(node, prefix=RTS_EXT_NS,
                                               local_name='Properties'):
            name, value = parse_properties_xml(c)
            self._properties[name] = value
        return self
Ejemplo n.º 12
0
 def _parse_xml(self, dom):
     self._reset()
     root = dom.documentElement
     # Get the attributes
     self.id = root.getAttributeNS(RTS_NS, 'id')
     self.abstract = root.getAttributeNS(RTS_NS, 'abstract')
     self.creation_date = root.getAttributeNS(RTS_NS, 'creationDate')
     self.update_date = root.getAttributeNS(RTS_NS, 'updateDate')
     self.version = root.getAttributeNS(RTS_NS, 'version')
     self.comment = root.getAttributeNS(RTS_EXT_NS, 'comment')
     # Parse the children
     for c in root.getElementsByTagNameNS(RTS_NS, 'Components'):
         self._components.append(Component().parse_xml_node(c))
     for c in root.getElementsByTagNameNS(RTS_NS, 'Groups'):
         self._groups.append(ComponentGroup().parse_xml_node(c))
     for c in root.getElementsByTagNameNS(RTS_NS, 'DataPortConnectors'):
         self._data_port_connectors.append(
             DataPortConnector().parse_xml_node(c))
     for c in root.getElementsByTagNameNS(RTS_NS, 'ServicePortConnectors'):
         self._service_port_connectors.append(
             ServicePortConnector().parse_xml_node(c))
     # These children should have zero or one
     c = root.getElementsByTagNameNS(RTS_NS, 'StartUp')
     if c.length > 0:
         if c.length > 1:
             raise InvalidRtsProfileNodeError('StartUp')
         self._startup = StartUp().parse_xml_node(c[0])
     c = root.getElementsByTagNameNS(RTS_NS, 'ShutDown')
     if c.length > 0:
         if c.length > 1:
             raise InvalidRtsProfileNodeError('ShutDown')
         self._shutdown = ShutDown().parse_xml_node(c[0])
     c = root.getElementsByTagNameNS(RTS_NS, 'Activation')
     if c.length > 0:
         if c.length > 1:
             raise InvalidRtsProfileNodeError('Activation')
         self._activation = Activation().parse_xml_node(c[0])
     c = root.getElementsByTagNameNS(RTS_NS, 'Deactivation')
     if c.length > 0:
         if c.length > 1:
             raise InvalidRtsProfileNodeError('Deactivation')
         self._deactivation = Deactivation().parse_xml_node(c[0])
     c = root.getElementsByTagNameNS(RTS_NS, 'Resetting')
     if c.length > 0:
         if c.length > 1:
             raise InvalidRtsProfileNodeError('Resetting')
         self._resetting = Resetting().parse_xml_node(c[0])
     c = root.getElementsByTagNameNS(RTS_NS, 'Initializing')
     if c.length > 0:
         if c.length > 1:
             raise InvalidRtsProfileNodeError('Initializing')
         self._initializing = Initializing().parse_xml_node(c[0])
     c = root.getElementsByTagNameNS(RTS_NS, 'Finalizing')
     if c.length > 0:
         if c.length > 1:
             raise InvalidRtsProfileNodeError('Finalizing')
         self._finalizing = Finalizing().parse_xml_node(c[0])
     # Extended profile children
     for c in root.getElementsByTagNameNS(RTS_EXT_NS, 'VersionUpLog'):
         if c.nodeType == c.TEXT_NODE:
             self._version_up_log.append(c.data)
         else:
             print('Warning: bad VersionUpLog node type.', file=sys.stderr)
     for c in get_direct_child_elements_xml(root,
                                            prefix=RTS_EXT_NS,
                                            local_name='Properties'):
         name, value = parse_properties_xml(c)
         self._properties[name] = value
Ejemplo n.º 13
0
 def _parse_xml(self, dom):
     self._reset()
     root = dom.documentElement
     # Get the attributes
     self.id = root.getAttributeNS(RTS_NS, 'id')
     self.abstract = root.getAttributeNS(RTS_NS, 'abstract')
     self.creation_date = root.getAttributeNS(RTS_NS, 'creationDate')
     self.update_date = root.getAttributeNS(RTS_NS, 'updateDate')
     self.version = root.getAttributeNS(RTS_NS, 'version')
     self.comment = root.getAttributeNS(RTS_EXT_NS, 'comment')
     # Parse the children
     for c in root.getElementsByTagNameNS(RTS_NS, 'Components'):
         self._components.append(Component().parse_xml_node(c))
     for c in root.getElementsByTagNameNS(RTS_NS, 'Groups'):
         self._groups.append(ComponentGroup().parse_xml_node(c))
     for c in root.getElementsByTagNameNS(RTS_NS, 'DataPortConnectors'):
         self._data_port_connectors.append(DataPortConnector().parse_xml_node(c))
     for c in root.getElementsByTagNameNS(RTS_NS, 'ServicePortConnectors'):
         self._service_port_connectors.append(ServicePortConnector().parse_xml_node(c))
     # These children should have zero or one
     c = root.getElementsByTagNameNS(RTS_NS, 'StartUp')
     if c.length > 0:
         if c.length > 1:
             raise InvalidRtsProfileNodeError('StartUp')
         self._startup = StartUp().parse_xml_node(c[0])
     c = root.getElementsByTagNameNS(RTS_NS, 'ShutDown')
     if c.length > 0:
         if c.length > 1:
             raise InvalidRtsProfileNodeError('ShutDown')
         self._shutdown = ShutDown().parse_xml_node(c[0])
     c = root.getElementsByTagNameNS(RTS_NS, 'Activation')
     if c.length > 0:
         if c.length > 1:
             raise InvalidRtsProfileNodeError('Activation')
         self._activation = Activation().parse_xml_node(c[0])
     c = root.getElementsByTagNameNS(RTS_NS, 'Deactivation')
     if c.length > 0:
         if c.length > 1:
             raise InvalidRtsProfileNodeError('Deactivation')
         self._deactivation = Deactivation().parse_xml_node(c[0])
     c = root.getElementsByTagNameNS(RTS_NS, 'Resetting')
     if c.length > 0:
         if c.length > 1:
             raise InvalidRtsProfileNodeError('Resetting')
         self._resetting = Resetting().parse_xml_node(c[0])
     c = root.getElementsByTagNameNS(RTS_NS, 'Initializing')
     if c.length > 0:
         if c.length > 1:
             raise InvalidRtsProfileNodeError('Initializing')
         self._initializing = Initializing().parse_xml_node(c[0])
     c = root.getElementsByTagNameNS(RTS_NS, 'Finalizing')
     if c.length > 0:
         if c.length > 1:
             raise InvalidRtsProfileNodeError('Finalizing')
         self._finalizing = Finalizing().parse_xml_node(c[0])
     # Extended profile children
     for c in root.getElementsByTagNameNS(RTS_EXT_NS, 'VersionUpLog'):
         if c.nodeType == c.TEXT_NODE:
             self._version_up_log.append(c.data)
         else:
             print('Warning: bad VersionUpLog node type.', file=sys.stderr)
     for c in get_direct_child_elements_xml(root, prefix=RTS_EXT_NS,
                                            local_name='Properties'):
         name, value = parse_properties_xml(c)
         self._properties[name] = value