def test_annotation(self):
     _xml = fromstring("<node x='0' y='0' id='0' shape='classic' " +
                       "background='#000000' padding='0' size='50'>" +
                       "<annotation>ExampleAnnotation</annotation></node>")
     node = Node()
     node.deserialize(_xml)
     self._check_annotation(node)
 def test_node(self):
     _xml = fromstring("<node x='0' y='0' id='0' shape='classic' " +
                       "background='#000000' height='50' width='100'>" +
                       "</node>")
     node = Node()
     node.deserialize(_xml)
     self._check_node(node)
 def test_text(self):
     _xml = fromstring("<node x='0' y='0' id='0' shape='classic' " +
                       "background='#000000' padding='0' size='50'>" +
                       "<text size='0' color='#000000' font='lol'>" +
                       "ExampleText</text></node>")
     node = Node()
     node.deserialize(_xml)
     self._check_text(node)
Exemple #4
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 #5
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"]