def __pnmlload__(cls, tree): result = new_instance(cls, module.PetriNet.__pnmlload__(tree)) try: result.clusters = tree.child(Cluster.__pnmltag__).to_obj() except snakes.SnakesError: result.clusters = Cluster() print("No cluster specified inside pnml - creating one") return result
def __pnmlload__ (cls, tree) : """ >>> m = MultiAction([Action('a', True, [Variable('x')]), ... Action('b', False, [Variable('y'), Value(2)])]) >>> t = Transition('t', actions=m).__pnmldump__() >>> Transition.__pnmlload__(t).actions MultiAction([Action('a', True, [Variable('x')]), Action('b', False, [Variable('y'), Value(2)])]) """ result = new_instance(cls, module.Transition.__pnmlload__(tree)) result.actions = Tree.to_obj(tree.child(MultiAction.__pnmltag__)) return result
def __pnmlload__ (cls, tree) : """ >>> t = Transition('p', status=Status('foo', 42)).__pnmldump__() >>> Transition.__pnmlload__(t).status Status('foo',42) """ result = new_instance(cls, module.Transition.__pnmlload__(tree)) try : result.status = tree.child("status").to_obj() except SnakesError : result.status = Status(None) return result
def __pnmlload__(cls, tree): """ >>> t = Transition('p', status=Status('foo', 42)).__pnmldump__() >>> Transition.__pnmlload__(t).status Status('foo',42) """ result = new_instance(cls, module.Transition.__pnmlload__(tree)) try: result.status = tree.child("status").to_obj() except SnakesError: result.status = Status(None) return result
def __pnmlload__(cls, tree): """ >>> m = MultiAction([Action('a', True, [Variable('x')]), ... Action('b', False, [Variable('y'), Value(2)])]) >>> t = Transition('t', actions=m).__pnmldump__() >>> Transition.__pnmlload__(t).actions MultiAction([Action('a', True, [Variable('x')]), Action('b', False, [Variable('y'), Value(2)])]) """ result = new_instance(cls, module.Transition.__pnmlload__(tree)) result.actions = Tree.to_obj(tree.child(MultiAction.__pnmltag__)) return result
def __pnmlload__ (cls, tree) : """ >>> old = PetriNet('n') >>> old.label(foo='bar', spam=42) >>> p = old.__pnmldump__() >>> new = PetriNet.__pnmlload__(p) >>> new PetriNet('n') >>> new.__class__ <class 'snakes.plugins.labels...PetriNet'> >>> new.label('foo', 'spam') ('bar', 42) """ n = new_instance(cls, module.PetriNet.__pnmlload__(tree)) n._labels = dict((lbl["name"], lbl.child().to_obj()) for lbl in tree.get_children("label")) return n
def __pnmlload__(cls, tree): """ >>> old = PetriNet('n') >>> old.label(foo='bar', spam=42) >>> p = old.__pnmldump__() >>> new = PetriNet.__pnmlload__(p) >>> new PetriNet('n') >>> new.__class__ <class 'snakes.plugins.labels.PetriNet'> >>> new.label('foo', 'spam') ('bar', 42) """ n = new_instance(cls, module.PetriNet.__pnmlload__(tree)) n._labels = dict((lbl["name"], lbl.child().to_obj()) for lbl in tree.get_children("label")) return n
def __pnmlload__(cls, tree): """ >>> old = Transition('t') >>> old.label(foo='bar', spam=42) >>> p = old.__pnmldump__() >>> new = Transition.__pnmlload__(p) >>> new Transition('t', Expression('True')) >>> new.__class__ <class 'snakes.plugins.labels.Transition'> >>> new.label('foo', 'spam') ('bar', 42) """ t = new_instance(cls, module.Transition.__pnmlload__(tree)) t._labels = dict((lbl["name"], lbl.child().to_obj()) for lbl in tree.get_children("label")) return t
def __pnmlload__(cls, tree): """ >>> old = Place('p') >>> old.label(foo='bar', spam=42) >>> p = old.__pnmldump__() >>> new = Place.__pnmlload__(p) >>> new Place('p', MultiSet([]), tAll) >>> new.__class__ <class 'snakes.plugins.labels.Place'> >>> new.label('foo', 'spam') ('bar', 42) """ p = new_instance(cls, module.Place.__pnmlload__(tree)) p._labels = dict((lbl["name"], lbl.child().to_obj()) for lbl in tree.get_children("label")) return p
def __pnmlload__ (cls, tree) : """ >>> old = Place('p') >>> old.label(foo='bar', spam=42) >>> p = old.__pnmldump__() >>> new = Place.__pnmlload__(p) >>> new Place('p', MultiSet([]), tAll) >>> new.__class__ <class 'snakes.plugins.labels...Place'> >>> new.label('foo', 'spam') ('bar', 42) """ p = new_instance(cls, module.Place.__pnmlload__(tree)) p._labels = dict((lbl["name"], lbl.child().to_obj()) for lbl in tree.get_children("label")) return p
def __pnmlload__ (cls, tree) : """ >>> old = Transition('t') >>> old.label(foo='bar', spam=42) >>> p = old.__pnmldump__() >>> new = Transition.__pnmlload__(p) >>> new Transition('t', Expression('True')) >>> new.__class__ <class 'snakes.plugins.labels...Transition'> >>> new.label('foo', 'spam') ('bar', 42) """ t = new_instance(cls, module.Transition.__pnmlload__(tree)) t._labels = dict((lbl["name"], lbl.child().to_obj()) for lbl in tree.get_children("label")) return t
def __pnmlload__(cls, tree): result = new_instance(cls, module.Transition.__pnmlload__(tree)) # time result.time = None # minimum duration try: result.min_time = tree.child("min_time").child().to_obj() except SnakesError: result.min_time = 0.0 # maximum duration try: result.max_time = tree.child("max_time").child().to_obj() except SnakesError: result.max_time = None return result
def __pnmlload__ (cls, tree) : """ >>> old = Transition('t', pos=(2, 1)) >>> p = old.__pnmldump__() >>> new = Transition.__pnmlload__(p) >>> new.pos Position(2, 1) >>> new Transition('t', Expression('True')) >>> new.__class__ <class 'snakes.plugins.pos.Transition'> """ result = new_instance(cls, module.Transition.__pnmlload__(tree)) try : p = tree.child("graphics").child("position") x, y = eval(p["x"]), eval(p["y"]) result.pos = Position(x, y) except SnakesError : result.pos = Position(0, 0) return result
def __pnmlload__ (cls, tree) : """ >>> old = Place('p', pos=(1, 2)) >>> p = old.__pnmldump__() >>> new = Place.__pnmlload__(p) >>> new.pos Position(1, 2) >>> new Place('p', MultiSet([]), tAll) >>> new.__class__ <class 'snakes.plugins.pos.Place'> """ result = new_instance(cls, module.Place.__pnmlload__(tree)) try : p = tree.child("graphics").child("position") x, y = eval(p["x"]), eval(p["y"]) result.pos = Position(x, y) except SnakesError : result.pos = Position(0, 0) return result
def __pnmlload__(cls, tree): """ >>> old = Place('p', pos=(1, 2)) >>> p = old.__pnmldump__() >>> new = Place.__pnmlload__(p) >>> new.pos Position(1, 2) >>> new Place('p', MultiSet([]), tAll) >>> new.__class__ <class 'snakes.plugins.pos.Place'> """ result = new_instance(cls, module.Place.__pnmlload__(tree)) try: p = tree.child("graphics").child("position") x, y = eval(p["x"]), eval(p["y"]) result.pos = Position(x, y) except SnakesError: result.pos = Position(0, 0) return result
def __pnmlload__(cls, tree): """ >>> old = Transition('t', pos=(2, 1)) >>> p = old.__pnmldump__() >>> new = Transition.__pnmlload__(p) >>> new.pos Position(2, 1) >>> new Transition('t', Expression('True')) >>> new.__class__ <class 'snakes.plugins.pos.Transition'> """ result = new_instance(cls, module.Transition.__pnmlload__(tree)) try: p = tree.child("graphics").child("position") x, y = eval(p["x"]), eval(p["y"]) result.pos = Position(x, y) except SnakesError: result.pos = Position(0, 0) return result
def __pnmlload__ (cls, tree) : t = new_instance(cls, module.PetriNet.__pnmlload__(tree)) t.status = StatusDict(t) return t
def __pnmlload__(cls, tree): t = new_instance(cls, module.PetriNet.__pnmlload__(tree)) t.status = StatusDict(t) return t
def __pnmlload__ (cls, tree) : result = new_instance(cls, module.PetriNet.__pnmlload__(tree)) result.clusters = tree.child(Cluster.__pnmltag__).to_obj() return result
def __pnmlload__(cls, tree): result = new_instance(cls, module.PetriNet.__pnmlload__(tree)) result.clusters = tree.child(Cluster.__pnmltag__).to_obj() return result