logilab.common.ureports package¶
Submodules¶
logilab.common.ureports.docbook_writer module¶
HTML formatting drivers for ureports
- class logilab.common.ureports.docbook_writer.DocbookWriter(snippet: Optional[int] = None)[source]¶
Bases:
HTMLWriter
format layouts as HTML
logilab.common.ureports.html_writer module¶
HTML formatting drivers for ureports
- class logilab.common.ureports.html_writer.HTMLWriter(snippet: Optional[int] = None)[source]¶
Bases:
BaseWriter
format layouts as HTML
- visit_section(layout: Section) None [source]¶
display a section as html, using div + h[section level]
- visit_verbatimtext(layout: VerbatimText) None [source]¶
display verbatim text (using <pre>)
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:
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, str]], Tuple[str, ...]] = (), **kwargs: Any)[source]¶
Bases:
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:
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: Optional[str] = None, **kwargs: Any)[source]¶
Bases:
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, str]], Tuple[str, ...]] = (), **kwargs: Any)[source]¶
Bases:
BaseLayout
some list data
attributes : * BaseLayout attributes
- class logilab.common.ureports.nodes.Paragraph(children: Union[List[Text], Tuple[Union[Paragraph, str], Union[List, str]], Tuple[str, ...]] = (), **kwargs: Any)[source]¶
Bases:
BaseLayout
a simple text paragraph
attributes : * BaseLayout attributes
A paragraph must not contains a section !
- class logilab.common.ureports.nodes.Section(title: Optional[str] = None, description: Optional[str] = None, **kwargs: Any)[source]¶
Bases:
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, str]], Tuple[str, ...]] = (), **kwargs: Any)[source]¶
Bases:
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: Any)[source]¶
Bases:
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: Any)[source]¶
Bases:
BaseComponent
a text portion
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:
BaseWriter
format layouts as text (ReStructured inspiration but not totally handled yet)
- default_table(layout: Table, table_content: List[List[str]], cols_width: List[int]) None [source]¶
format a table
- field_table(layout: Table, table_content: List[List[str]], cols_width: List[int]) None [source]¶
special case for field table
- visit_verbatimtext(layout: VerbatimText) None [source]¶
display a verbatim layout as text (so difficult ;)
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: 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: Optional[Union[StringIO, TextIO]] = 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