- @property
- def top(self):
- """Get a list of all top-level actions."""
- return [dfn for name, dfn in self.actions.items()
- if name and name.startswith("top")]
+ This attempts to autodetect if the stream is XML or YAML.
+ """
+ if not hasattr(source, 'read'):
+ source = StringIO(source)
+ start = source.read(1)
+ source.seek(0)
+ if start == "<":
+ return cls.FromXML(source)
+ elif start == "!" or start == "#":
+ return cls.FromYAML(source)
+ else:
+ raise ParseError("unknown initial character %r" % start)