Link: start Link: parent Link: First page in set (first) Link: Previous page (previous) Link: Next page (next) Link: Last page in set (last) Link: A plain text version of this page (alternate) Link: The XIST source of this page (alternate) Link: The Python module described in this page (alternate) XIST.present ============ Module with classes for printing trees ====================================== Home > Python software > ll.xist > present Text · XIST · Python Python softwarelist of projects * ll.xistAn extensible XML/HTML generator * ExamplesParsing/creating/modifying XML; Traversing XML trees * HowtoExplains parsing/generating XML files, XML transformations via XIST classes and other basic concepts. * SearchingHow to iterate through XIST trees * TransformationHow to transform XIST trees * Advanced topicsPool chaining, converter contexts, validation * MiscellaneousExplains various odds and ends of XIST * xscXIST core classes * nsPackage containing namespace modules * parseParsing XML * presentScreen output of XML trees * simsSimple schema validation * xfindTree iteration and filtering * cssCSS related functions * scriptsScripts for text conversion and creating XIST namespaces * HistoryChangeLog for XIST * InstallationHow to install and configure XIST * MigrationHow to update your code to new versions of XIST * Mailing listsHow to subscribe to the XIST mailing lists * ll.ul4cA templating language * ll.urlRFC 2396 compliant URLs * ll.makeObject oriented make replacement * ll.daemonForking daemon processes * ll.sisyphusWriting cron jobs with Python * ll.colorRGB color values and color model conversion * ll.miscMisc utility functions and classes * ll.orasqlUtilities for cx_Oracle * ll.nightshadeServe the output of Oracle functions/procedures with CherryPy * ll.scriptsScripts for UL4 template rendering and URL handling * AploraLogging Apache HTTP requests to an Oracle database * PycocoPython code coverage * DownloadLinks to Windows and Linux, source and binary distributions * Source codeAccess to the Mercurial repositories This module contains presenter classes, which are used for displaying XIST nodes on screen (either on the terminal or via ipipe browsers). 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): ============================================== def __iter__(self): ==================== def __xattrs__(self, mode='default'): ====================================== class TreePresenter(Presenter): ================================ This presenter shows the object as a nested tree. def __init__(self, node, indent=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). 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 defaultpresenter(Presenter): =================================== This presenter shows the object as a nested tree. def __init__(self, node, indent=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). 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). def __str__(self): =================== def __iter__(self): ==================== def _indent(self): =================== def _text(self, text): ======================= def presentFrag(self, node): ============================= def _formatattrvalue(self, attrvalue): ======================================= 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): ============================= def displayhook(obj): ======================