16 from io
import BytesIO
17 from os
import fsdecode
20 from .robottypes
import is_bytes, is_pathlike, is_string
23 from xml.etree
import cElementTree
as ET
26 from xml.etree
import ElementTree
as ET
28 raise ImportError(
'No valid ElementTree XML parser module found')
45 return BytesIO(source)
47 return BytesIO(source.encode(encoding))
58 return not source.lstrip().startswith(prefix)
64 match = re.match(
r"\s*<\?xml .*encoding=(['\"])(.*?)\1.*\?>", source)
65 return match.group(2)
if match
else 'UTF-8'
67 def __exit__(self, exc_type, exc_value, exc_trace):
75 if hasattr(source,
'name'):
77 return '<in-memory file>'
def _is_already_open(self, source)
def _open_if_necessary(self, source)
def _find_encoding(self, source)
def _path_to_string(self, path)
def _is_path(self, source)
def __init__(self, source)
def __exit__(self, exc_type, exc_value, exc_trace)