X-Git-Url: https://git.yukkurigames.com/?p=python-bulletml.git;a=blobdiff_plain;f=bulletml%2Fparser.py;h=e9b0488c5aa75f570a5867a42b48d036e38ec8b8;hp=487009330bf1f824b38cf0f76f082a5c094fd83e;hb=0153a3d87b036f4afaf78e3815a2ad981def4993;hpb=405e333fe99b3625b0d89565de4e83984b462a3e diff --git a/bulletml/parser.py b/bulletml/parser.py index 4870093..e9b0488 100644 --- a/bulletml/parser.py +++ b/bulletml/parser.py @@ -710,41 +710,41 @@ class BulletML(object): tree = ElementTree() root = tree.parse(source) - self = cls(type=root.get("type", "none")) + doc = cls(type=root.get("type", "none")) - self._bullets = {} - self._actions = {} - self._fires = {} - self._bullet_refs = [] - self._action_refs = [] - self._fire_refs = [] + doc._bullets = {} + doc._actions = {} + doc._fires = {} + doc._bullet_refs = [] + doc._action_refs = [] + doc._fire_refs = [] for element in root.getchildren(): tag = realtag(element) - if tag in self.CONSTRUCTORS: - self.CONSTRUCTORS[tag].FromXML(self, element) + if tag in doc.CONSTRUCTORS: + doc.CONSTRUCTORS[tag].FromXML(doc, element) try: - for ref in self._bullet_refs: - ref.bullet = self._bullets[ref.bullet] - for ref in self._fire_refs: - ref.fire = self._fires[ref.fire] - for ref in self._action_refs: - ref.action = self._actions[ref.action] + for ref in doc._bullet_refs: + ref.bullet = doc._bullets[ref.bullet] + for ref in doc._fire_refs: + ref.fire = doc._fires[ref.fire] + for ref in doc._action_refs: + ref.action = doc._actions[ref.action] except KeyError as exc: raise ParseError("unknown reference %s" % exc) - self.actions = [act for name, act in self._actions.items() + doc.actions = [act for name, act in doc._actions.items() if name and name.startswith("top")] - del(self._bullet_refs) - del(self._action_refs) - del(self._fire_refs) - del(self._bullets) - del(self._actions) - del(self._fires) + del(doc._bullet_refs) + del(doc._action_refs) + del(doc._fire_refs) + del(doc._bullets) + del(doc._actions) + del(doc._fires) - return self + return doc @classmethod def FromYAML(cls, source): @@ -780,9 +780,8 @@ class BulletML(object): raise ParseError("unknown initial character %r" % start) def __repr__(self): - return "%s(type=%r, bullets=%r, actions=%r, fires=%r)" % ( - type(self).__name__, self.type, self.bullets, self.actions, - self.fires) + return "%s(type=%r, actions=%r)" % ( + type(self).__name__, self.type, self.actions) ActionDef.CONSTRUCTORS = dict( repeat=Repeat,