Exemple #1
0
 def deserialize(self, xml):
     if xml.text and re.search(r"\w", str(xml.text)):
         raise ValueError(
             "Project shouldn't have text value! But has:\n'" +
             xml.text + "'")
     if xml.attrib.keys():
         raise AttributeError(
             "Project shouldn't have attributes!" +
             "\nDiff: " + str(xml.attrib.keys()))
     for node in xml.iterfind("node"):
         n = Node()
         n.deserialize(node)
         self.nodes[n.id] = n
     for edge in xml.iterfind("edge"):
         e = Edge()
         e.deserialize(edge)
         self.edges[e.id] = e
Exemple #2
0
 def deserialize(self, xml):
     if xml.text and re.search(r"\w", str(xml.text)):
         raise ValueError(
             "Project shouldn't have text value! But has:\n'" +
             xml.text + "'")
     if xml.attrib.keys() == ["width", "height"]:
         raise AttributeError(
             "Project have only width and height attributes!" +
             "\nDiff: " + str(self.attribute_diff(
                 xml.attrib.keys(), ["width", "height"])))
     for node in xml.iterfind("node"):
         n = Node()
         n.deserialize(node)
         self.nodes[n.id] = n
     for edge in xml.iterfind("edge"):
         e = Edge()
         e.deserialize(edge)
         self.edges[e.id] = e
     self.workspace_width = xml.attrib["width"]
     self.workspace_height = xml.attrib["height"]
 def test_edge(self):
     _xml = fromstring("<edge type='auto' x='0' y='0' thickness='50' " +
                       "color='#ffffff' node1='540' node2='0' />")
     edge = Edge()
     edge.deserialize(_xml)
     self._check_edge(edge)