X-Git-Url: https://git.yukkurigames.com/?p=python-bulletml.git;a=blobdiff_plain;f=bulletml%2Fbulletyaml.py;h=2503c9d7fa757f97208ac2d3ea6b1744a919fcc0;hp=ea45436d2e47482a199d110168a80c57d90ee3d4;hb=bf5ff1d116840e1330c80894132919ec515596e4;hpb=29b24c8fc17a3bdcccd1ac853eee5b90c6fd0856 diff --git a/bulletml/bulletyaml.py b/bulletml/bulletyaml.py index ea45436..2503c9d 100644 --- a/bulletml/bulletyaml.py +++ b/bulletml/bulletyaml.py @@ -13,7 +13,7 @@ Example BulletYAML document: !BulletML type: vertical actions: - top: !ActionDef + - !ActionDef actions: - !FireDef bullet: !BulletDef {} @@ -33,13 +33,16 @@ def register(Loader=None, Dumper=None): parser.BulletML]: def add(cls, loader, dumper): + """Register a class in a new variable scope.""" tag = "!" + cls.__name__ if loader: def construct(loader, node): + """Construct an object.""" return loader.construct_yaml_object(node, cls) loader.add_constructor(tag, construct) if dumper: def represent(dumper, obj): + """Represent an object.""" return dumper.represent_yaml_object(tag, obj, cls) dumper.add_representer(cls, represent)