From bc6dd530488535b2edeff9afbbdde896aed73046 Mon Sep 17 00:00:00 2001 From: Joe Wreschnig Date: Sat, 20 Mar 2010 00:21:10 -0700 Subject: [PATCH] Fix muscle memory writing bad code. --- bulletml/parser.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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: -- 2.30.2