def FromXML(cls, doc, element): """Construct using an ElementTree-style element.""" for subelem in element.getchildren(): tag = realtag(subelem) if tag == "speed": speed = Speed.FromXML(doc, subelem) elif tag == "term": term = INumberDef(subelem.text) try: return cls(term, speed) except UnboundLocalError as exc: raise ParseError(str(exc))
def FromXML(cls, doc, element): """Construct using an ElementTree-style element.""" for subelem in element.getchildren(): tag = realtag(subelem) if tag == "times": times = INumberDef(subelem.text) elif tag == "action": action = ActionDef.FromXML(doc, subelem) elif tag == "actionRef": action = ActionRef.FromXML(doc, subelem) try: return cls(times, action) except UnboundLocalError as exc: raise ParseError(str(exc))
def FromXML(cls, doc, element): """Construct using an ElementTree-style element.""" else_ = None for subelem in element.getchildren(): tag = realtag(subelem) if tag == "cond": cond = INumberDef(subelem.text) elif tag == "then": then = ActionDef.FromXML(doc, subelem) elif tag == "else": else_ = ActionDef.FromXML(doc, subelem) try: return cls(cond, then, else_) except UnboundLocalError as exc: raise ParseError(str(exc))
def FromXML(cls, doc, element): """Construct using an ElementTree-style element.""" horizontal = None vertical = None for subelem in element.getchildren(): tag = realtag(subelem) if tag == "term": term = INumberDef(subelem.text) elif tag == "horizontal": horizontal = Speed.FromXML(doc, subelem) elif tag == "vertical": vertical = Speed.FromXML(doc, subelem) try: return cls(term, horizontal, vertical) except AttributeError: raise ParseError
def __setstate__(self, state): state = dict(state) self.__init__(INumberDef(state["frames"]), state.get("horizontal"), state.get("vertical"))
def __setstate__(self, state): state = dict(state) state["else_"] = state.pop("else", None) state["cond"] = INumberDef(state["cond"]) self.__init__(**state)
def __setstate__(self, state): state = dict(state) self.__init__(INumberDef(state["times"]), state["action"])
def FromXML(cls, doc, element): """Construct using an ElementTree-style element.""" return cls(INumberDef(element.text))
def __setstate__(self, state): self.__init__(INumberDef(state["frames"]))
def __setstate__(self, state): state = dict(state) self.__init__(INumberDef(state["frames"]), Speed(state["type"], NumberDef(state["value"])))