projects
/
python-bulletml.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
bbceff0
)
Python 3 support.
author
Joe Wreschnig
<joe.wreschnig@gmail.com>
Thu, 18 Mar 2010 09:37:36 +0000
(
02:37
-0700)
committer
Joe Wreschnig
<joe.wreschnig@gmail.com>
Thu, 18 Mar 2010 09:37:36 +0000
(
02:37
-0700)
bulletml/parser.py
patch
|
blob
|
history
diff --git
a/bulletml/parser.py
b/bulletml/parser.py
index
de3e817
..
2ad648c
100644
(file)
--- a/
bulletml/parser.py
+++ b/
bulletml/parser.py
@@
-14,9
+14,12
@@
import math
from xml.etree.ElementTree import ElementTree
try:
from xml.etree.ElementTree import ElementTree
try:
- from
cStringIO
import StringIO
+ from
io
import StringIO
except ImportError:
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
from bulletml.errors import Error
from bulletml.expr import NumberDef, INumberDef
@@
-524,7
+527,7
@@
class BulletML(object):
@classmethod
def FromDocument(cls, source):
"""Return a BulletML instance based on a string or file-like."""
@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()
source = StringIO(source)
tree = ElementTree()
@@
-564,7
+567,7
@@
class BulletML(object):
@property
def top(self):
"""Get a list of all top-level actions."""
@property
def top(self):
"""Get a list of all top-level actions."""
- return [dfn for name, dfn in self.actions.ite
rite
ms()
+ return [dfn for name, dfn in self.actions.items()
if name and name.startswith("top")]
def __repr__(self):
if name and name.startswith("top")]
def __repr__(self):