示例#1
0
文件: pos.py 项目: lbzhao28/snakes
 def __pnmldump__ (self) :
     """
     >>> p = Place('p', pos=(1, 2))
     >>> p.__pnmldump__()
     <?xml version="1.0" encoding="utf-8"?>
     <pnml>
      <place id="p">
       <type domain="universal"/>
       <initialMarking>
        <multiset/>
       </initialMarking>
       <graphics>
        <position x="1" y="2"/>
       </graphics>
      </place>
     </pnml>
     """
     t = module.Place.__pnmldump__(self)
     try :
         gfx = t.child("graphics")
     except SnakesError :
         gfx = Tree("graphics", None)
         t.add_child(gfx)
     gfx.add_child(Tree("position", None,
                        x=str(self.pos.x),
                        y=str(self.pos.y)))
     return t
示例#2
0
文件: clusters.py 项目: balrok/snakes
 def __pnmldump__(self):
     """
     >>> Cluster(['a', 'b'],
     ...         [Cluster(['1', '2'],
     ...                  [Cluster(['A'])]),
     ...          Cluster(['3', '4', '5'],
     ...                  [Cluster(['C', 'D'])])]).__pnmldump__()
     <?xml version="1.0" encoding="utf-8"?>
     <pnml>...
      <clusters>
       <node>
       ...
       </node>
       <node>
       ...
       </node>
       <clusters>
       ...
       </clusters>
      </clusters>
     </pnml>
     """
     result = Tree(self.__pnmltag__, None)
     for node in self._nodes:
         result.add_child(Tree("node", node))
     for child in self._children:
         result.add_child(Tree.from_obj(child))
     return result
示例#3
0
 def __pnmldump__(self):
     """
     >>> p = Place('p', pos=(1, 2))
     >>> p.__pnmldump__()
     <?xml version="1.0" encoding="utf-8"?>
     <pnml>
      <place id="p">
       <type domain="universal"/>
       <initialMarking>
        <multiset/>
       </initialMarking>
       <graphics>
        <position x="1" y="2"/>
       </graphics>
      </place>
     </pnml>
     """
     t = module.Place.__pnmldump__(self)
     try:
         gfx = t.child("graphics")
     except SnakesError:
         gfx = Tree("graphics", None)
         t.add_child(gfx)
     gfx.add_child(
         Tree("position", None, x=str(self.pos.x), y=str(self.pos.y)))
     return t
示例#4
0
 def __pnmldump__ (self) :
     """
     >>> Cluster(['a', 'b'],
     ...         [Cluster(['1', '2'],
     ...                  [Cluster(['A'])]),
     ...          Cluster(['3', '4', '5'],
     ...                  [Cluster(['C', 'D'])])]).__pnmldump__()
     <?xml version="1.0" encoding="utf-8"?>
     <pnml>...
      <clusters>
       <node>
       ...
       </node>
       <node>
       ...
       </node>
       <clusters>
       ...
       </clusters>
      </clusters>
     </pnml>
     """
     result = Tree(self.__pnmltag__, None)
     for node in self._nodes :
         result.add_child(Tree("node", node))
     for child in self._children :
         result.add_child(Tree.from_obj(child))
     return result
示例#5
0
 def __pnmldump__(self):
     """
     >>> Action('a', True, [Value(1), Variable('x')]).__pnmldump__()
     <?xml version="1.0" encoding="utf-8"?>
     <pnml>...
      <action name="a" send="True">
       <value>
        <object type="int">1</object>
       </value>
       <variable>x</variable>
      </action>
     </pnml>
     """
     result = Tree(
         self.__pnmltag__, None, name=self.name, send=str(self.send))
     for param in self.params:
         result.add_child(Tree.from_obj(param))
     return result
示例#6
0
 def __pnmldump__ (self) :
     """
     >>> Action('a', True, [Value(1), Variable('x')]).__pnmldump__()
     <?xml version="1.0" encoding="utf-8"?>
     <pnml>...
      <action name="a" send="True">
       <value>
        <object type="int">1</object>
       </value>
       <variable>x</variable>
      </action>
     </pnml>
     """
     result = Tree(self.__pnmltag__, None,
                   name=self.name,
                   send=str(self.send))
     for param in self.params :
         result.add_child(Tree.from_obj(param))
     return result