From: Joe Wreschnig Date: Sat, 20 Mar 2010 07:21:10 +0000 (-0700) Subject: Fix muscle memory writing bad code. X-Git-Url: https://git.yukkurigames.com/?a=commitdiff_plain;h=bc6dd530488535b2edeff9afbbdde896aed73046;p=python-bulletml.git Fix muscle memory writing bad code. --- diff --git a/bulletml/parser.py b/bulletml/parser.py index 8f253fe..b2e078b 100644 --- a/bulletml/parser.py +++ b/bulletml/parser.py @@ -25,7 +25,7 @@ from bulletml.errors import Error from bulletml.expr import NumberDef, INumberDef -__all_ = ["ParseError", "BulletML"] +__all__ = ["ParseError", "BulletML"] class ParseError(Error): """Raised when an error occurs parsing the XML structure.""" @@ -358,7 +358,7 @@ class BulletDef(object): direction = None speed = None - def __init__(self, actions=[], direction=None, speed=None, tags=()): + def __init__(self, actions=(), direction=None, speed=None, tags=()): self.direction = direction self.speed = speed self.actions = list(actions) @@ -386,6 +386,7 @@ class BulletDef(object): actions = [] speed = None direction = None + tags = set() for subelem in element.getchildren(): tag = realtag(subelem) if tag == "direction": @@ -397,8 +398,8 @@ class BulletDef(object): elif tag == "actionRef": actions.append(ActionRef.FromXML(doc, subelem)) elif tag == "tag": - self.tags.add(subelem.text) - dfn = cls(actions, direction, speed) + tags.add(subelem.text) + dfn = cls(actions, direction, speed, tags) doc._bullets[element.get("label")] = dfn return dfn @@ -613,6 +614,7 @@ class FireDef(object): direction = None speed = None offset = None + tags = set() for subelem in element.getchildren(): tag = realtag(subelem) @@ -627,9 +629,9 @@ class FireDef(object): elif tag == "offset": offset = Offset.FromXML(doc, subelem) elif tag == "tag": - self.tags.add(subelem.text) + tags.add(subelem.text) try: - fire = cls(bullet, direction, speed, offset) + fire = cls(bullet, direction, speed, offset, tags) except UnboundLocalError as exc: raise ParseError(str(exc)) else: