6 Copyright (C) 2009-2010 8 RT-Synthesis Research Group 9 Intelligent Systems Research Institute, 10 National Institute of Advanced Industrial Science and Technology (AIST), 13 Licensed under the Eclipse Public License -v 1.0 (EPL) 14 http://www.opensource.org/licenses/eclipse-1.0.txt 16 File: component_group.py 18 Object representing a component group. 22 __version__ =
'$Revision: $' 26 from rtsprofile
import RTS_NS, RTS_NS_S
34 '''A group of components in the RT system.''' 39 @param group_id ID of the group. 41 @param members Members of the group. At least one must be present. 46 expected_type=[str, unicode], required=
False)
49 expected_type=list, required=
False)
53 result =
'Group ID: {0}\n'.format(self.
group_id)
55 result +=
'Members:\n' 57 result +=
' {0}\n'.format(m)
62 '''The ID used to distinguish this group in the RT system.''' 68 expected_type=[str, unicode], required=
True)
73 '''A list of the components in the group. 75 At least one must be present. 83 expected_type=list, required=
True)
87 '''Parse an xml.dom Node object representing a component group into 91 self.
group_id = node.getAttributeNS(RTS_NS,
'groupId')
93 for c
in node.getElementsByTagNameNS(RTS_NS,
'Members'):
98 '''Parse a YAML specification of a component group into this 105 for m
in y.get(
'members'):
106 self._members.append(TargetComponent().
parse_yaml(m))
110 '''Save this component group into an xml.dom.Element object.''' 111 element.setAttributeNS(RTS_NS, RTS_NS_S +
'groupID', self.
group_id)
113 new_element = doc.createElementNS(RTS_NS, RTS_NS_S +
'Members')
114 m.save_xml(doc, new_element)
115 element.appendChild(new_element)
118 '''Save this component group to a dictionary.''' 122 members.append(m.to_dict())
124 d[
'members'] = members
def save_xml(self, doc, element)
def validate_attribute(attr, name, expected_type=None, required=False)
def __init__(self, group_id='', members=[])
def parse_xml_node(self, node)
def parse_yaml(self, node)