from xml.etree.ElementTree import ElementTree
try:
- from cStringIO import StringIO
+ from io import StringIO
except ImportError:
- from StringIO import StringIO
+ try:
+ from cStringIO import StringIO
+ except ImportError:
+ from StringIO import StringIO
from bulletml.errors import Error
from bulletml.expr import NumberDef, INumberDef
@classmethod
def FromDocument(cls, source):
"""Return a BulletML instance based on a string or file-like."""
- if isinstance(source, (str, unicode)):
+ if not hasattr(source, 'read'):
source = StringIO(source)
tree = ElementTree()
@property
def top(self):
"""Get a list of all top-level actions."""
- return [dfn for name, dfn in self.actions.iteritems()
+ return [dfn for name, dfn in self.actions.items()
if name and name.startswith("top")]
def __repr__(self):