This module contains presenter classes, which are used for formatting XIST trees into various formats.
def strtab(count):
def strtext(text):
class Presenter(object):
This class is the base of the presenter classes. It is abstract and only serves as documentation for the methods.
A Presenter generates a specific string representation of a node
to be printed on the screen.
def __init__(self, node):
def presentText(self, *args, **kwargs):
Present a ll.xist.xsc.Text node.
def presentFrag(self, *args, **kwargs):
Present a ll.xist.xsc.Frag node.
def presentComment(self, *args, **kwargs):
Present a ll.xist.xsc.Comment node.
def presentDocType(self, *args, **kwargs):
Present a ll.xist.xsc.DocType node.
def presentProcInst(self, *args, **kwargs):
Present a ll.xist.xsc.ProcInst node.
def presentAttrs(self, *args, **kwargs):
Present an ll.xist.xsc.Attrs node.
def presentElement(self, *args, **kwargs):
Present an ll.xist.xsc.Element node.
def presentEntity(self, *args, **kwargs):
Present a ll.xist.xsc.Entity node.
def presentNull(self, *args, **kwargs):
Present the ll.xist.xsc.Null node.
def presentAttr(self, *args, **kwargs):
Present an ll.xist.xsc.Attr node.
class Line(object):
def __init__(self, node, loc, path, content):
class TreePresenter(Presenter):
This presenter shows the object as a nested tree.
def __init__(self, node, indent=None, defaultxmlns=None):
Create a TreePresenter object for the XIST node node using
indent for indenting each tree level. If indent is
None use the value of the environment variable LL_XIST_INDENT
as the indent string (falling back to a tab if the environment variable
doesn't exist).
If defaultxmlns is not None, elements from this namespace will
be output without any namespace name.
def __str__(self):
def strindent(self, level):
def text(self, text):
def __iter__(self):
def _domultiline(self, node, lines, indent, formatter, head=None, tail=None):
def presentFrag(self, node):
def presentAttrs(self, node):
def presentElement(self, node):
def presentNull(self, node):
def presentText(self, node):
def presentEntity(self, node):
def presentProcInst(self, node):
def presentComment(self, node):
def presentDocType(self, node):
def presentAttr(self, node):
class CodePresenter(Presenter):
This presenter formats the object as a nested Python object tree.
This makes it possible to quickly convert HTML/XML files to XIST constructor calls.
def __init__(self, node, indent=None):
Create a CodePresenter object for the XIST node node using
indent for indenting each tree level. If indent is
None use the value of the environment variable LL_XIST_INDENT
as the indent string (falling back to a tab if the environment variable
doesn't exist).