示例#1
0
 def save_xml(self, doc, element):
     '''Save this component into an xml.dom.Element object.'''
     element.setAttributeNS(XSI_NS, XSI_NS_S + 'type',
                            'rtsExt:component_ext')
     element.setAttributeNS(RTS_NS, RTS_NS_S + 'id', self.id)
     element.setAttributeNS(RTS_NS, RTS_NS_S + 'pathUri', self.path_uri)
     if self.active_configuration_set:
         element.setAttributeNS(RTS_NS, RTS_NS_S + 'activeConfigurationSet',
                                self.active_configuration_set)
     element.setAttributeNS(RTS_NS, RTS_NS_S + 'instanceName',
                            self.instance_name)
     element.setAttributeNS(RTS_NS, RTS_NS_S + 'compositeType',
                            comp_type.to_string(self.composite_type))
     element.setAttributeNS(RTS_NS, RTS_NS_S + 'isRequired',
                            str(self.is_required).lower())
     if self.comment:
         element.setAttributeNS(RTS_EXT_NS, RTS_EXT_NS_S + 'comment',
                                self.comment)
     element.setAttributeNS(RTS_EXT_NS, RTS_EXT_NS_S + 'visible',
                            str(self.visible).lower())
     for port in self.data_ports:
         new_element = doc.createElementNS(RTS_NS, RTS_NS_S + 'DataPorts')
         port.save_xml(doc, new_element)
         element.appendChild(new_element)
     for port in self.service_ports:
         new_element = doc.createElementNS(RTS_NS,
                                           RTS_NS_S + 'ServicePorts')
         port.save_xml(doc, new_element)
         element.appendChild(new_element)
     for cs in self.configuration_sets:
         new_element = doc.createElementNS(RTS_NS,
                                           RTS_NS_S + 'ConfigurationSets')
         cs.save_xml(doc, new_element)
         element.appendChild(new_element)
     for ec in self.execution_contexts:
         new_element = doc.createElementNS(RTS_NS,
                                           RTS_NS_S + 'ExecutionContexts')
         ec.save_xml(doc, new_element)
         element.appendChild(new_element)
     for p in self.participants:
         new_element = doc.createElementNS(RTS_NS,
                                           RTS_NS_S + 'Participants')
         p.save_xml(doc, new_element)
         element.appendChild(new_element)
     new_element = doc.createElementNS(RTS_EXT_NS,
                                       RTS_EXT_NS_S + 'Location')
     self._location.save_xml(doc, new_element)
     element.appendChild(new_element)
     for p in self.properties:
         new_prop_element = doc.createElementNS(RTS_EXT_NS,
                                                RTS_EXT_NS_S + 'Properties')
         properties_to_xml(new_prop_element, p, self.properties[p])
         element.appendChild(new_prop_element)
示例#2
0
 def save_xml(self, doc, element):
     '''Save this component into an xml.dom.Element object.'''
     element.setAttributeNS(XSI_NS, XSI_NS_S + 'type', 'rtsExt:component_ext')
     element.setAttributeNS(RTS_NS, RTS_NS_S + 'id', self.id)
     element.setAttributeNS(RTS_NS, RTS_NS_S + 'pathUri', self.path_uri)
     if self.active_configuration_set:
         element.setAttributeNS(RTS_NS, RTS_NS_S + 'activeConfigurationSet',
                                self.active_configuration_set)
     element.setAttributeNS(RTS_NS, RTS_NS_S + 'instanceName',
                            self.instance_name)
     element.setAttributeNS(RTS_NS, RTS_NS_S + 'compositeType',
                            comp_type.to_string(self.composite_type))
     element.setAttributeNS(RTS_NS, RTS_NS_S + 'isRequired',
                            str(self.is_required).lower())
     if self.comment:
         element.setAttributeNS(RTS_EXT_NS, RTS_EXT_NS_S + 'comment',
                                self.comment)
     element.setAttributeNS(RTS_EXT_NS, RTS_EXT_NS_S + 'visible',
                            str(self.visible).lower())
     for port in self.data_ports:
         new_element = doc.createElementNS(RTS_NS, RTS_NS_S + 'DataPorts')
         port.save_xml(doc, new_element)
         element.appendChild(new_element)
     for port in self.service_ports:
         new_element = doc.createElementNS(RTS_NS,
                                           RTS_NS_S + 'ServicePorts')
         port.save_xml(doc, new_element)
         element.appendChild(new_element)
     for cs in self.configuration_sets:
         new_element = doc.createElementNS(RTS_NS,
                                           RTS_NS_S + 'ConfigurationSets')
         cs.save_xml(doc, new_element)
         element.appendChild(new_element)
     for ec in self.execution_contexts:
         new_element = doc.createElementNS(RTS_NS,
                                           RTS_NS_S + 'ExecutionContexts')
         ec.save_xml(doc, new_element)
         element.appendChild(new_element)
     for p in self.participants:
         new_element = doc.createElementNS(RTS_NS,
                                           RTS_NS_S + 'Participants')
         p.save_xml(doc, new_element)
         element.appendChild(new_element)
     new_element = doc.createElementNS(RTS_EXT_NS,
                                       RTS_EXT_NS_S + 'Location')
     self._location.save_xml(doc, new_element)
     element.appendChild(new_element)
     for p in self.properties:
         new_prop_element = doc.createElementNS(RTS_EXT_NS,
                                                RTS_EXT_NS_S + 'Properties')
         properties_to_xml(new_prop_element, p, self.properties[p])
         element.appendChild(new_prop_element)
示例#3
0
    def to_dict(self):
        d = {
            'id': self.id,
            'pathUri': self.path_uri,
            'instanceName': self.instance_name,
            'compositeType': comp_type.to_string(self.composite_type),
            'isRequired': self.is_required,
            RTS_EXT_NS_YAML + 'visible': self.visible
        }
        if self.active_configuration_set:
            d['activeConfigurationSet'] = self.active_configuration_set
        if self.comment:
            d[RTS_EXT_NS_YAML + 'comment'] = self.comment

        ports = []
        for p in self.data_ports:
            ports.append(p.to_dict())
        if ports:
            d['dataPorts'] = ports
        ports = []
        for p in self.service_ports:
            ports.append(p.to_dict())
        if ports:
            d['servicePorts'] = ports
        sets = []
        for cs in self.configuration_sets:
            sets.append(cs.to_dict())
        if sets:
            d['configurationSets'] = sets
        ecs = []
        for ec in self.execution_contexts:
            ecs.append(ec.to_dict())
        if ecs:
            d['executionContexts'] = ecs
        participants = []
        for p in self.participants:
            participants.append(p.to_dict())
        if participants:
            d['participants'] = participants

        d[RTS_EXT_NS_YAML + 'location'] = self._location.to_dict()
        props = []
        for name in self.properties:
            p = {'name': name}
            if self.properties[name]:
                p['value'] = str(self.properties[name])
            props.append(p)
        if props:
            d[RTS_EXT_NS_YAML + 'properties'] = props

        return d
示例#4
0
    def to_dict(self):
        d = {'id': self.id,
                'pathUri': self.path_uri,
                'instanceName': self.instance_name,
                'compositeType': comp_type.to_string(self.composite_type),
                'isRequired': self.is_required,
                RTS_EXT_NS_YAML + 'visible': self.visible}
        if self.active_configuration_set:
            d['activeConfigurationSet'] = self.active_configuration_set
        if self.comment:
            d[RTS_EXT_NS_YAML + 'comment'] = self.comment

        ports = []
        for p in self.data_ports:
            ports.append(p.to_dict())
        if ports:
            d['dataPorts'] = ports
        ports = []
        for p in self.service_ports:
            ports.append(p.to_dict())
        if ports:
            d['servicePorts'] = ports
        sets = []
        for cs in self.configuration_sets:
            sets.append(cs.to_dict())
        if sets:
            d['configurationSets'] = sets
        ecs = []
        for ec in self.execution_contexts:
            ecs.append(ec.to_dict())
        if ecs:
            d['executionContexts'] = ecs
        participants = []
        for p in self.participants:
            participants.append(p.to_dict())
        if participants:
            d['participants'] = participants

        d[RTS_EXT_NS_YAML + 'location'] = self._location.to_dict()
        props = []
        for name in self.properties:
            p = {'name': name}
            if self.properties[name]:
                p['value'] = str(self.properties[name])
            props.append(p)
        if props:
            d[RTS_EXT_NS_YAML + 'properties'] = props

        return d
示例#5
0
    def __str__(self):
        result = 'Instance name: {3}\n  ID: {0}\n  Path URI: {1}\n  Active \
configuration set: {2}\n  Composite type: {4}\n  Is required: {5}\n'                                                                    .format(\
                self.id, self.path_uri, self.active_configuration_set,
                self.instance_name, comp_type.to_string(self.composite_type),
                self.is_required)
        if self.comment:
            result += '  Comment: {0}\n'.format(self.comment)
        result += '  Visible: {0}\n'.format(self.visible)
        if self.data_ports:
            result += '  Data ports:\n'
            for p in self.data_ports:
                result += '{0}\n'.format(indent_string(str(p), num_spaces=4))
        if self.service_ports:
            result += '  Service ports:\n'
            for p in self.service_ports:
                result += '{0}\n'.format(indent_string(str(p), num_spaces=4))
        if self.configuration_sets:
            result += '  Configuration sets:\n'
            for c in self.configuration_sets:
                result += '{0}\n'.format(indent_string(str(c), num_spaces=4))
        if self.execution_contexts:
            result += '  Execution contexts:\n'
            for e in self.execution_contexts:
                result += '{0}\n'.format(indent_string(str(e), num_spaces=4))
        if self.participants:
            result += '  Participants:\n'
            for p in self.participants:
                result += '{0}\n'.format(indent_string(str(p)))
        result += '  Location:\n{0}\n'.format(
            indent_string(str(self.location), num_spaces=4))
        if self.properties:
            result += '  Properties:\n'
            for p in self.properties:
                result += '    {0}: {1}\n'.format(p, self.properties[p])
        return result[:-1]  # Lop off the last new line
示例#6
0
    def __str__(self):
        result = 'Instance name: {3}\n  ID: {0}\n  Path URI: {1}\n  Active \
configuration set: {2}\n  Composite type: {4}\n  Is required: {5}\n'.format(\
                self.id, self.path_uri, self.active_configuration_set,
                self.instance_name, comp_type.to_string(self.composite_type),
                self.is_required)
        if self.comment:
            result += '  Comment: {0}\n'.format(self.comment)
        result += '  Visible: {0}\n'.format(self.visible)
        if self.data_ports:
            result += '  Data ports:\n'
            for p in self.data_ports:
                result += '{0}\n'.format(indent_string(str(p), num_spaces=4))
        if self.service_ports:
            result += '  Service ports:\n'
            for p in self.service_ports:
                result += '{0}\n'.format(indent_string(str(p), num_spaces=4))
        if self.configuration_sets:
            result += '  Configuration sets:\n'
            for c in self.configuration_sets:
                result += '{0}\n'.format(indent_string(str(c), num_spaces=4))
        if self.execution_contexts:
            result += '  Execution contexts:\n'
            for e in self.execution_contexts:
                result += '{0}\n'.format(indent_string(str(e), num_spaces=4))
        if self.participants:
            result += '  Participants:\n'
            for p in self.participants:
                result += '{0}\n'.format(indent_string(str(p)))
        result += '  Location:\n{0}\n'.format(indent_string(str(self.location),
                                                           num_spaces=4))
        if self.properties:
            result += '  Properties:\n'
            for p in self.properties:
                result += '    {0}: {1}\n'.format(p, self.properties[p])
        return result[:-1] # Lop off the last new line