Ejemplo n.º 1
0
 def endElement(self, tag):
     if tag == "o:Table" and self.current_table is not None:
         if "code" in self.current_table.keys():
             t = Table()
             for key, val in self.current_table.items():
                 t.__setattr__(key, val)
             self.tables.append(t)
         self.current_table = None
         self.table_map[t.id] = t
     elif tag == "o:Column":
         if "name" in self.current_column.keys():
             c = Column()
             for key, val in self.current_column.items():
                 if key == 'col_type':
                     c.col_type = PdmColumnType[val.upper()]
                 else:
                     c.__setattr__(key, val)
             self.current_table['columns'].append(c)
         self.current_column = None
     elif tag == "a:Name":
         self.current_attr = None
     elif tag == "a:Code":
         self.current_attr = None
     elif tag == "a:DataType":
         self.current_attr = None
     elif tag == "a:Comment":
         self.current_attr = None
     elif tag == "o:Reference" and 'child' in self.current_ref.keys(
     ) and 'parent' in self.current_ref.keys():
         if self.current_ref['child'] not in self.refs.keys():
             self.refs[self.current_ref['child']] = []
         ref = self.refs[self.current_ref['child']]
         ref.append(self.current_ref['parent'])
         self.current_ref = None
     elif self.current_ref is not None and tag == "c:ParentTable":
         self.current_ref['parent'] = self.current_parent_table
         self.current_parent_table = None
     elif self.current_ref is not None and tag == "c:ChildTable":
         self.current_ref['child'] = self.current_child_table
         self.current_child_table = None