Content container for a report like document.
The report container is independent from its output format. It can have text paragraphs, headings, tables (pandas.DataFrame), images and figures.
| Class | |
Control several page layout aspects. |
| Class | |
Ordered or unordered enumeration. |
| Class | |
Content element representing a heading element. |
| Class | |
An image content element. |
| Class | |
Content element representing a text paragraph. |
| Class | |
Reference list, e.g. TOC, Figure, Tables. |
| Class | |
Content element representing a data table. |
| Static Method | image |
Create a bytes object from an image file or a plotted figure. |
| Method | __getitem__ |
Use the report with a [] operator like a list. |
| Method | __init__ |
Initiate a report instance. |
| Method | __len__ |
Return the number of elements. |
| Method | auto |
Use temporary default tags for new elements. |
| Method | enumeration |
Enumeration element. |
| Method | get |
Return only elements that fit the tag rules. |
| Method | heading |
Add a heading element. |
| Method | heading |
Modify the current heading level. |
| Method | heading |
Create headings on a none persistent level. |
| Method | image |
Image or plotted figure as report element. |
| Method | image |
Add a bunch of images at once via (nested) dictionary. |
| Method | list |
Add list of figures element. |
| Method | list |
Add list of tables element. |
| Method | page |
Just a page break. |
| Method | page |
Page break with landscape orientation. |
| Method | page |
Page break with portrait orientation. |
| Method | paragraph |
Add a paragraph element. |
| Method | section |
Open a section and return it as a child report object. |
| Method | subtitle |
Subtitle for the document. |
| Method | table |
Table element as pandas.DataFrame. |
| Method | table |
Add a bunch of tables at once via (nested) dictionary. |
| Method | table |
Generate a table of content element. |
| Method | title |
Title of the report. |
| Method | toggle |
Toggle the current existing page orientation. |
| Method | _add |
Add a report element to the list and taking care of (auto) tags. |
| Method | _page |
Page break including specific page orientation. |
| Instance Variable | _current |
These tags are added by default to new elements. |
| Instance Variable | _current |
The current activate heading level. |
| Instance Variable | _element |
Tags for each element in _elements with the same index. |
| Instance Variable | _elements |
List of all elements of that report. |
| Instance Variable | _heading |
Internally used with child-reports. |
| Instance Variable | _xlsx |
Undocumented |
def image_to_bytes(file_path_or_figure:
pathlib.Path | matplotlib.figure.Figure | matplotlib.axes.Axes | seaborn.axisgrid._BaseGrid) -> bytes:
(source)
¶
Create a bytes object from an image file or a plotted figure.
Use temporary default tags for new elements.
Example
import report r = report.Report() r.paragraph('Paragraph without a tag') with r.auto_tags(['short', 'boss']): r.paragraph('Paragraph with tags "short" and "boss".') r.table(pandas.DataFrame()) # tagged table r.paragraph('Another paragraph without a tag.')
| Parameters | |
tags:list | str | One tag or a list of tags. |
| Returns | |
Report | The instance itself. |
Iterable[ str], ordered: bool, style: str = None, tags: list | str = None):
(source)
¶
Enumeration element.
When used with DocxDocument the visual result is sligthely different from the regular MS Words enumeration. For example the idention is missing. Another limitation is that nested enumerations are not supported.
| Parameters | |
items:Iterable[ | List of enumeration items as strings. |
ordered:bool | Use bullet points (False) or numbers (True). |
style:str | If used this overwrites ordered argument. |
tags:list | str | One or more tags for that element. |
Iterable[ str] = None, tags_excluded: Iterable[ str] = None) -> NamedTuple:
(source)
¶
Return only elements that fit the tag rules.
It is a generator. Exclusion tags have higher priority then allowed tags. In practice it means that if an element have tag from tag_allowed and tags_excluded it is excluded from that generator.
| Parameters | |
tagsIterable[ | Allowed tags. |
tagsIterable[ | Tags to exclude. |
| Returns | |
NamedTuple | Undocumented |
| Yields | |
| Elements that fitting the tag rules. | |
str, *, level: int = None, up: bool = None, down: bool = None, persistent: bool = True, tags: list | str = None):
(source)
¶
Add a heading element.
| Parameters | |
text:str | The heading string. |
level:int | The level (starting with 1). |
up:bool | Decrease current level and use that for this heading. |
down:bool | Increase current level and use that for this heading. |
persistent:bool | Stay on the level if True (default). |
tags:list | str | One or more tags for that element. |
str, *, level: int = None, up: bool = None, down: bool = None, tags: list | str = None):
(source)
¶
Create headings on a none persistent level.
It is a wrapper for heading(). None persistent means that the used
level is set back to the previous level before that method was
called.
pathlib.Path | matplotlib.figure.Figure | matplotlib.axes.Axes | seaborn.axisgrid._BaseGrid | bytes, scale_factor: float = None, caption: str = None, tags: list | str = None):
(source)
¶
Image or plotted figure as report element.
| Parameters | |
filepathlib.Path | matplotlib.figure.Figure | matplotlib.axes.Axes | seaborn.axisgrid._BaseGrid | bytes | File or plot instance. |
scalefloat | Float scaling factor from 0.0 to 1.0. |
caption:str | String used as image caption. |
tags:list | str | One or more tags for that element. |
str = 'List of Figures', tags: list | str = None):
(source)
¶
Add list of figures element.
pandas.DataFrame, caption: str = None, *, note: str = None, autofit: bool = True, tags: list | str = None):
(source)
¶
Table element as pandas.DataFrame.
| Parameters | |
dataframe:pandas.DataFrame | The data object. |
caption:str | String used as table caption. |
note:str | String used as (foot)note. |
autofit:bool | Adjust table width via autofit? |
tags:list | str | One or more tag for that element. |
dict, page_break: bool = False, autofit: bool = True, tags: list | str = None):
(source)
¶
Add a bunch of tables at once via (nested) dictionary.
The keys in that dictionary are used as heading or caption.
| Parameters | |
dataframedict | (Nested) dictionary of pandas.DataFrame's. |
pagebool | New page after each table? |
autofit:bool | Set autofit to each the table. |
tags:list | str | Tag that element. |
Toggle the current existing page orientation.
This will effect all past elements until the last page break.
Add a report element to the list and taking care of (auto) tags.
The instance attribute _current_auto_tags is taken into account.
| Parameters | |
element:NamedTuple | Report | The element. |
tags:list | str | One or more tags used for that element. |