16 from .markuputils
import attribute_escape, html_escape, xml_escape
17 from .robottypes
import is_string, is_pathlike
18 from .robotio
import file_writer
29 def __init__(self, output, write_empty=True, usage=None):
39 def start(self, name, attrs=None, newline=True):
40 attrs = self._format_attrs(attrs)
41 self._start(name, attrs, newline)
43 def _start(self, name, attrs, newline):
44 self.
_write_write(
'<%s %s>' % (name, attrs)
if attrs
else '<%s>' % name, newline)
52 if write_empty
or value)
57 def content(self, content=None, escape=True, newline=False):
59 self.
_write_write(self.
_escape_escape(content)
if escape
else content, newline)
62 raise NotImplementedError
64 def end(self, name, newline=True):
65 self.
_write_write(
'</%s>' % name, newline)
67 def element(self, name, content=None, attrs=None, escape=True, newline=True):
70 self.
_start_start(name, attrs, newline=
False)
71 self.
contentcontent(content, escape)
72 self.
endend(name, newline)
78 def _write(self, text, newline=False):
87 return sorted(attrs.items())
96 self.
_write_write(
'<?xml version="1.0" encoding="UTF-8"?>', newline=
True)
101 def element(self, name, content=None, attrs=None, escape=True, newline=True):
103 _MarkupWriter.element(self, name, content, attrs, escape, newline)
110 self.
_write_write(
'<%s %s/>' % (name, attrs)
if attrs
else '<%s/>' % name, newline)
116 __init__ = start = content = element = end = close =
lambda *args, **kwargs:
None
def _order_attrs(self, attrs)
def _escape(self, content)
Null implementation of the _MarkupWriter interface.
def _self_closing_element(self, name, attrs, newline)
def element(self, name, content=None, attrs=None, escape=True, newline=True)
def _start(self, name, attrs, newline)
def _order_attrs(self, attrs)
def element(self, name, content=None, attrs=None, escape=True, newline=True)
def __init__(self, output, write_empty=True, usage=None)
:param output: Either an opened, file like object, or a path to the desired output file.
def start(self, name, attrs=None, newline=True)
def end(self, name, newline=True)
def _escape(self, content)
def _format_attrs(self, attrs)
def close(self)
Closes the underlying output file.
def content(self, content=None, escape=True, newline=False)
def _write(self, text, newline=False)
def write(msg, level='INFO', html=False)
Writes the message to the log file using the given level.
def html_escape(text, linkify=True)
def attribute_escape(attr)
def file_writer(path=None, encoding='UTF-8', newline=None, usage=None)