예제 #1
0
 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))
예제 #2
0
 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))
예제 #3
0
 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))
예제 #4
0
    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
예제 #5
0
 def __setstate__(self, state):
     state = dict(state)
     self.__init__(INumberDef(state["frames"]), state.get("horizontal"),
                   state.get("vertical"))
예제 #6
0
 def __setstate__(self, state):
     state = dict(state)
     state["else_"] = state.pop("else", None)
     state["cond"] = INumberDef(state["cond"])
     self.__init__(**state)
예제 #7
0
 def __setstate__(self, state):
     state = dict(state)
     self.__init__(INumberDef(state["times"]), state["action"])
예제 #8
0
 def FromXML(cls, doc, element):
     """Construct using an ElementTree-style element."""
     return cls(INumberDef(element.text))
예제 #9
0
 def __setstate__(self, state):
     self.__init__(INumberDef(state["frames"]))
예제 #10
0
 def __setstate__(self, state):
     state = dict(state)
     self.__init__(INumberDef(state["frames"]),
                   Speed(state["type"], NumberDef(state["value"])))