16 from io
import BytesIO
18 from .compat
import py2to3
19 from .platform
import IRONPYTHON, PY_VERSION
20 from .robottypes
import is_string
23 IRONPYTHON_WITH_BROKEN_ETREE = IRONPYTHON
and PY_VERSION < (2, 7, 9)
24 NO_ETREE_ERROR =
'No valid ElementTree XML parser module found'
27 if not IRONPYTHON_WITH_BROKEN_ETREE:
29 from xml.etree
import cElementTree
as ET
32 from xml.etree
import ElementTree
as ET
34 raise ImportError(NO_ETREE_ERROR)
39 from elementtree
import ElementTree
as ET
41 raise ImportError(NO_ETREE_ERROR)
42 from StringIO
import StringIO
46 if ET.VERSION <
'1.3' and hasattr(ET,
'tostringlist'):
61 def __exit__(self, exc_type, exc_value, exc_trace):
68 if hasattr(self.
_source_source,
'name'):
70 return '<in-memory file>'
74 and not self.
_source_source.lstrip().startswith(
'<')
79 if IRONPYTHON_WITH_BROKEN_ETREE:
80 return StringIO(self.
_source_source)
81 return BytesIO(self.
_source_source.encode(
'UTF-8'))
def _open_source_if_necessary(self)
def _source_is_file_name(self)
def __exit__(self, exc_type, exc_value, exc_trace)
def __init__(self, source)