simple_report.page module¶
- class simple_report.page.PageBuffer(status='default')[source]¶
Bases:
objectBuffer used to accomplish nesting of elements - leave this alone
- Parameters:
status (str)
- add_to_buffer(html, prepend=False)[source]¶
Add html to the content buffer
- Parameters:
html (str) – The HTML string to add
prepend (bool) – Prepend the new HTML string to the buffer if true or append (default)
- add_to_html(html, prepend=False)[source]¶
Add html to the internal buffer
- Parameters:
html (str) – The HTML string to add
prepend (bool) – Prepend the new HTML string to the buffer if true or append (default)
- content_buffer¶
- content_ids¶
- html¶
- info¶
- status¶
- class simple_report.page.ReportPage(report_dir, page_name, config, color_map, subpage=None, color_mode='light')[source]¶
Bases:
objectSingle page of a Report object, does all the heavy lifting
- Parameters:
report_dir (str | Path)
page_name (str)
config (dict[str, Any])
color_map (ColorMap)
subpage (bool | None)
color_mode (str)
- add_accordion_item(name)[source]¶
Adds a new card to the accordion
- Parameters:
name (str) – Name as shown in the card before opening
- add_custom_html_code(html)[source]¶
Add your own html code to the page
- Parameters:
html (str) – Whatever you want to add
- add_error_warning_info_section(errors=None, warnings=None, info=None)[source]¶
Add a section containing errors/warnings/infos
If a report ball is provided it takes precedence over the other lists.
- Parameters:
errors (Optional[list[str]]) – List of errors encountered
warnings (Optional[list[str]]) – List of warnings encountered
info (Optional[list[str]]) – List of info encountered
- add_header(header_text, color=None)[source]¶
Add a section header to the page
- Parameters:
header_text (str) – Header text
color (Optional[str]) – Color of the header box
- add_image(image_source, remove_source=None, responsive=None, center=None)[source]¶
Add an image to the page
- Parameters:
image_source (Union[str, Path]) – Path to image that needs to be added The image will be copied to report/page/images/
remove_source (Optional[bool]) – If true the source will be deleted and we will only keep the copy in the report dir
responsive (Optional[bool]) – If true the image will automatically be resized to match the outer container
center (Optional[bool]) – If true the image will be centered
- add_list(list_items)[source]¶
Add a list to the page
- Parameters:
list_items (list[str]) – Each item is converted to a bullet point
- add_local_link(link)[source]¶
Add a clickable link to the page
- Parameters:
link (str) – HTML link to another page. You either created this link yourself or you used the Reporter to get the link to another page.
Adds a new nav pill to the navbar
- Parameters:
name (str) – Name as shown in the pill
- add_report_header(name, date=None, include_date=True, color='primary')[source]¶
Add the main report header to the page
- Parameters:
name (str) – Report name
date (Optional[Union[str, int, datetime.date, datetime.datetime]]) – Report date
include_date (bool) – Include the date in the header, default is True
color (str) – Background color of header
- add_sub_header(header_text, color=None, sub_level=None)[source]¶
Add a section header to the page
- Parameters:
header_text (str) – Header text
color (Optional[str]) – Color of the header box
sub_level (Optional[int]) – Shrinks the width of the header box. Levels can be 1 to 5. The higher the level the smaller the box
- add_tab(name)[source]¶
Add a new tab to the tabs list
- Parameters:
name (str) – Name as shown in the tab list
- add_table(table_data, formatters=None, options=None, size=None, align=None, caption=None, footers=None, order=None, color=None)[source]¶
Add a table to the page.
table_datacan either be a pandasDataFrameor a list of lists. For the former we assume indices and column labels are already properly formatted. For the latter we assume the first item contains the headers.- Parameters:
table_data (Union[DataFrame, list[list[Any]]]) – Data to tabelize.
formatters (Optional[Union[str, Callable, list[str], list[Callable]]]) – Formatters applied to each table element. If a list is provided it must match the number of columns. A single formatter is applied to all columns. The default formatter is
str().options (Optional[list[str]]) –
Turn optional elements of the DataTable on. Supported options:
page- Split long tables into pages of 10 (configurable)info- Show number of rowssearch- Add a search fieldno_sort- Disable initial sortingcolor_negative_values- Highlight values < 0 in redcolor_positive_values- Highlight values > 0 in greenfull_width- Table spans full window width
size (Optional[int]) – Sets the width of the table (1-12).
12uses full container width.align (Optional[str]) – Alignment of cell content.
caption (Optional[str]) – Text shown below the table.
footers (Optional[list[list[Any]]]) – Rows always shown at the bottom of the table.
order (Optional[list[list[Any]]]) – Default table order in the form
[[col_idx, 'asc' | 'desc'], ...].color (Optional[str]) – Text color. Automatically determined if omitted.
- add_text(text, color=None, align=None)[source]¶
Add (colored) text to the page
This will create a new paragraph. So if you want to mix colors within one paragraph you’ll have to do this yourself for now
- Parameters:
text (str) – Your text
color (Optional[str]) – One of the supported colors
align (Optional[Literal['left', 'center', 'right']]) – Alignment of text
Close current navbar environment
- get_link_to_page(link_name=None, for_navbar=False)[source]¶
Get a relative link to the current page
- Parameters:
link_name (Optional[str]) – Clickable text for the link
for_navbar (bool) – The link will be part of a navbar. This is used for global link bars. You will probably never need this.
- Returns:
str - HTML code for the link
- Return type:
str
- open_accordion(color=None)[source]¶
Open an accordion environment
- Parameters:
color (Optional[str]) – Color of navbar pills
Open a navbar environment
- Parameters:
loc (Optional[Literal['left', 'right', 'top']]) – Position of navbar pills
color (Optional[Literal['gray', 'red', 'blue', 'green']]) – Color of navbar pills