16 from io
import BytesIO
18 from .htmlreader
import HtmlReader
19 from .robotreader
import RobotReader
23 from .restsupport
import (publish_doctree, publish_from_doctree,
28 def read(self, rstfile, rawdata):
29 doctree = publish_doctree(
30 rstfile.read(), source_path=rstfile.name,
32 'input_encoding':
'UTF-8',
35 store = RobotDataStorage(doctree)
37 return self._read_text(store.get_data(), rawdata, rstfile.name)
38 return self._read_html(doctree, rawdata, rstfile.name)
40 def _read_text(self, data, rawdata, path):
41 robotfile = BytesIO(data.encode(
'UTF-8'))
44 def _read_html(self, doctree, rawdata, path):
46 htmlfile.write(publish_from_doctree(
47 doctree, writer_name=
'html',
48 settings_overrides={
'output_encoding':
'UTF-8'}))
50 return HtmlReader().read(htmlfile, rawdata, path)