def parse_blocks(self):
     parsed_block_list = []
     for block in self.block_list_xml.getchildren():
         tagname = block.tag
         # apparently I started using two different xml
         # protocols as some point
         if tagname.lower() != 'block' and block.attrib:
             name = block.attrib['name']
             blocktype = block.tag
             params = get_params(block)
         elif tagname.lower() == 'block':
             # I guess this is the newer style based on
             # xml_utils and block_diagram_gui.py
             name = xml_utils.get_child_value(block,'name')
             blocktype = xml_utils.get_child_value(block,\
                                                   'blocktype')
             params = xml_utils.get_params(block)
         #kwargs = children_to_dict(block)
         if class_map1.has_key(blocktype):
             myclass = class_map1[blocktype]
         else:
             myclass = block_diagram_xml.bd_XML_element
         cur_block = myclass(name=name, \
                             blocktype=blocktype, \
                             params=params)
         cur_block.cleanup_params()
         parsed_block_list.append(cur_block)
     self.parsed_block_list = parsed_block_list
示例#2
0
 def parse(self):
     """convert the XML associated with self to a list something
     ready to be converted to a bd_XML_element instance"""
     body = self.validate_and_get_body()
     self.name = xml_utils.get_child_value(body, 'name')
     self.blocktype = xml_utils.get_child_value(body, 'blocktype')
     self.params = xml_utils.get_params(body)