Fix muscle memory writing bad code.
authorJoe Wreschnig <joe.wreschnig@gmail.com>
Sat, 20 Mar 2010 07:21:10 +0000 (00:21 -0700)
committerJoe Wreschnig <joe.wreschnig@gmail.com>
Sat, 20 Mar 2010 07:21:10 +0000 (00:21 -0700)
bulletml/parser.py

index 8f253fe7a09d722ebded8d296d4c8f0a9d64def6..b2e078b739a5153596f91fbb0af1c59ffd4aad3b 100644 (file)
@@ -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: