logilab.common.ureports package¶
Submodules¶
logilab.common.ureports.docbook_writer module¶
HTML formatting drivers for ureports
-
class
logilab.common.ureports.docbook_writer.
DocbookWriter
(snippet: int = None)[source]¶ Bases:
logilab.common.ureports.html_writer.HTMLWriter
format layouts as HTML
logilab.common.ureports.html_writer module¶
HTML formatting drivers for ureports
-
class
logilab.common.ureports.html_writer.
HTMLWriter
(snippet: int = None)[source]¶ Bases:
logilab.common.ureports.BaseWriter
format layouts as HTML
-
visit_paragraph
(layout: logilab.common.ureports.nodes.Paragraph) → None[source]¶ display links (using <p>)
-
logilab.common.ureports.nodes module¶
Micro reports objects.
A micro report is a tree of layout and content objects.
-
class
logilab.common.ureports.nodes.
BaseComponent
(id: Optional[str] = None, klass: Optional[str] = None)[source]¶ Bases:
logilab.common.tree.VNode
base report component
attributes * id : the component’s optional id * klass : the component’s optional klass
-
class
logilab.common.ureports.nodes.
BaseLayout
(children: Union[List[Text], Tuple[Union[Paragraph, str], Union[List[T], str]], Tuple[str, ...]] = (), **kwargs)[source]¶ Bases:
logilab.common.ureports.nodes.BaseComponent
base container node
attributes * BaseComponent attributes * children : components in this table (i.e. the table’s cells)
-
class
logilab.common.ureports.nodes.
Image
(filename, stream, title=None, **kwargs)[source]¶ Bases:
logilab.common.ureports.nodes.BaseComponent
an embedded or a single image
attributes : * BaseComponent attributes * filename : the image’s filename (REQUIRED) * stream : the stream object containing the image data (REQUIRED) * title : the image’s optional title
-
class
logilab.common.ureports.nodes.
Link
(url: str, label: str = None, **kwargs)[source]¶ Bases:
logilab.common.ureports.nodes.BaseComponent
a labelled link
attributes : * BaseComponent attributes * url : the link’s target (REQUIRED) * label : the link’s label as a string (use the url by default)
-
class
logilab.common.ureports.nodes.
List
(children: Union[List[Text], Tuple[Union[Paragraph, str], Union[List[T], str]], Tuple[str, ...]] = (), **kwargs)[source]¶ Bases:
logilab.common.ureports.nodes.BaseLayout
some list data
attributes : * BaseLayout attributes
-
class
logilab.common.ureports.nodes.
Paragraph
(children: Union[List[Text], Tuple[Union[Paragraph, str], Union[List[T], str]], Tuple[str, ...]] = (), **kwargs)[source]¶ Bases:
logilab.common.ureports.nodes.BaseLayout
a simple text paragraph
attributes : * BaseLayout attributes
A paragraph must not contains a section !
-
class
logilab.common.ureports.nodes.
Section
(title: str = None, description: str = None, **kwargs)[source]¶ Bases:
logilab.common.ureports.nodes.BaseLayout
a section
attributes : * BaseLayout attributes
a title may also be given to the constructor, it’ll be added as a first element a description may also be given to the constructor, it’ll be added as a first paragraph
-
class
logilab.common.ureports.nodes.
Span
(children: Union[List[Text], Tuple[Union[Paragraph, str], Union[List[T], str]], Tuple[str, ...]] = (), **kwargs)[source]¶ Bases:
logilab.common.ureports.nodes.BaseLayout
a title
attributes : * BaseLayout attributes
A span should only contains Text and Link nodes (in-line elements)
-
class
logilab.common.ureports.nodes.
Table
(cols: int, title: Optional[Any] = None, rheaders: int = 0, cheaders: int = 0, rrheaders: int = 0, rcheaders: int = 0, **kwargs)[source]¶ Bases:
logilab.common.ureports.nodes.BaseLayout
some tabular data
attributes : * BaseLayout attributes * cols : the number of columns of the table (REQUIRED) * rheaders : the first row’s elements are table’s header * cheaders : the first col’s elements are table’s header * title : the table’s optional title
-
class
logilab.common.ureports.nodes.
Text
(data: str, escaped: bool = True, **kwargs)[source]¶ Bases:
logilab.common.ureports.nodes.BaseComponent
a text portion
attributes : * BaseComponent attributes * data : the text value as an encoded or unicode string
-
class
logilab.common.ureports.nodes.
Title
(children: Union[List[Text], Tuple[Union[Paragraph, str], Union[List[T], str]], Tuple[str, ...]] = (), **kwargs)[source]¶ Bases:
logilab.common.ureports.nodes.BaseLayout
a title
attributes : * BaseLayout attributes
A title must not contains a section nor a paragraph!
-
class
logilab.common.ureports.nodes.
VerbatimText
(data: str, escaped: bool = True, **kwargs)[source]¶ Bases:
logilab.common.ureports.nodes.Text
a verbatim text, display the raw data
attributes : * BaseComponent attributes * data : the text value as an encoded or unicode string
logilab.common.ureports.text_writer module¶
Text formatting drivers for ureports
-
class
logilab.common.ureports.text_writer.
TextWriter
[source]¶ Bases:
logilab.common.ureports.BaseWriter
format layouts as text (ReStructured inspiration but not totally handled yet)
-
default_table
(layout: logilab.common.ureports.nodes.Table, table_content: List[List[str]], cols_width: List[int]) → None[source]¶ format a table
-
field_table
(layout: logilab.common.ureports.nodes.Table, table_content: List[List[str]], cols_width: List[int]) → None[source]¶ special case for field table
-
visit_list
(layout: logilab.common.ureports.nodes.List) → None[source]¶ display a list layout as text
-
Module contents¶
Universal report objects and some formatting drivers.
A way to create simple reports using python objects, primarily designed to be formatted as text and html.
-
class
logilab.common.ureports.
BaseWriter
[source]¶ Bases:
object
base class for ureport writers
-
compute_content
(layout: logilab.common.tree.VNode) → Generator[str, Any, None][source]¶ trick to compute the formatting of children layout before actually writing it
return an iterator on strings (one for each child element)
-
format
(layout: Any, stream: Union[_io.StringIO, TextIO, None] = None, encoding: Optional[Any] = None) → None[source]¶ format and write the given layout into the stream object
unicode policy: unicode strings may be found in the layout; try to call stream.write with it, but give it back encoded using the given encoding if it fails
-
format_children
(layout: Union[Paragraph, Section, Title]) → None[source]¶ recurse on the layout children and call their accept method (see the Visitor pattern)
-
-
logilab.common.ureports.
build_summary
(layout, level=1)[source]¶ make a summary for the report, including X level