Content container for a report like document independent from its output format.
Such a report can have text paragraphs, headings, tables ( pandas.DataFrame), images and figures.
Class |
|
An element controlling page breaks, orientation and insertion of auto generated reference lists like table of contents. |
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__ |
No summary |
Method | auto |
Use temporary default tags for new elements. |
Method | get |
Generator returning only that elements fitting the tag rules. |
Method | heading |
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:
Union[ 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:Union[ | One tag or a list of tags. |
Returns | |
Report | The instance itself. |
Iterable[ str]
= None, tags_excluded: Iterable[ str]
= None) -> NamedTuple
:
(source)
¶
Generator returning only that elements fitting the tag rules.
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: Union[ list, str]
= None):
(source)
¶
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:Union[ | One or more tags for that element. |
str
, level: int
= None, up: bool
= None, down: bool
= None, tags: Union[ 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.
Union[ pathlib.Path, matplotlib.figure.Figure, matplotlib.axes.Axes, seaborn.axisgrid._BaseGrid, bytes]
, scale_factor: float
= None, caption: str
= None, tags: Union[ list, str]
= None):
(source)
¶
Image or plotted figure as report element.
Parameters | |
fileUnion[ | File or plot instance. |
scalefloat | Float scaling factor from 0.0 to 1.0. |
caption:str | String used as image caption. |
tags:Union[ | One or more tags for that element. |
str
= 'List of Figures', tags: Union[ list, str]
= None):
(source)
¶
Add list of figures element.
str
= 'List of Tables', tags: Union[ list, str]
= None):
(source)
¶
Add list of tables element.
pandas.DataFrame
, caption: str
= None, note: str
= None, autofit: bool
= True, tags: Union[ 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:Union[ | One or more tag for that element. |
dict
, page_break: bool
= False, autofit: bool
= True, tags: Union[ 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:Union[ | Tag that element. |
Toggle the current existing page orientation.
This will effect all past elements until the last page break.
Union[ NamedTuple, Report]
, tags: Union[ list, str]
= None):
(source)
¶
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:Union[ | The element. |
tags:Union[ | One or more tags used for that element. |