Bullet tagging. (Fixes issue #7)
[python-bulletml.git] / bulletml / parser.py
index a07cc2d..de3e817 100644 (file)
@@ -170,6 +170,28 @@ class Wait(object):
     def __repr__(self):
         return "%s(%r)" % (type(self).__name__, self.frames)
 
+class Tag(object):
+    """Set a bullet tag."""
+
+    def __init__(self, tag):
+        self.tag = tag
+
+    @classmethod
+    def FromElement(cls, doc, element):
+        """Construct using an ElementTree-style element."""
+        return cls(element.text)
+
+class Untag(object):
+    """Unset a bullet tag."""
+
+    def __init__(self, tag):
+        self.tag = tag
+
+    @classmethod
+    def FromElement(cls, doc, element):
+        """Construct using an ElementTree-style element."""
+        return cls(element.text)
+
 class Vanish(object):
     """Make the owner disappear."""
 
@@ -551,13 +573,15 @@ class BulletML(object):
             self.fires)
 
 ActionDef.CONSTRUCTORS = dict(
-        repeat=Repeat,
-        fire=FireDef,
-        fireRef=FireRef,
-        changeSpeed=ChangeSpeed,
-        changeDirection=ChangeDirection,
-        accel=Accel,
-        wait=Wait,
-        vanish=Vanish,
-        action=ActionDef,
-        actionRef=ActionRef)
+    repeat=Repeat,
+    fire=FireDef,
+    fireRef=FireRef,
+    changeSpeed=ChangeSpeed,
+    changeDirection=ChangeDirection,
+    accel=Accel,
+    wait=Wait,
+    vanish=Vanish,
+    tag=Tag,
+    untag=Untag,
+    action=ActionDef,
+    actionRef=ActionRef)