basic_report.page module

class basic_report.page.PageBuffer(status='default')[source]

Bases: object

Buffer 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 basic_report.page.ReportPage(report_dir, page_name, config, color_map, subpage=None, color_mode='light')[source]

Bases: object

Single 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_calendar_heatmap(*, misc=None, domain=None, label=None, subdomain=None, date=None, color=None, x=None, y=None, custom_config=None)[source]

Add a calendar heatmap to the report

Parameters:
  • misc (CalendarMisc | None) – The miscellaneous configuration for the calendar heatmap

  • domain (CalendarDomain | None) – The domain configuration for the calendar heatmap

  • label (CalendarLabel | None) – The label configuration for the calendar heatmap

  • subdomain (CalendarSubDomain | None) – (CalendarSubDomain | None): The subdomain configuration for the calendar heatmap

  • date (CalendarDate | None) – The date configuration for the calendar heatmap

  • color (CalendarColor | None) – The color configuration for the calendar heatmap

  • x (list[str] | None) – The time data array, e.g., dates

  • y (list[float | int] | None) – The corresponding value array

  • custom_config (dict[str, Any] | None) – A custom config dict to easily override any defaults set in the report. See the documentation for the calendar heatmap for an in depth discussion of the available parameters

add_card(*, background_color=None, border_color=None, image=None, header_text=None, header_text_color=None, header_background_color=None, header_border_color=None, footer_text=None, footer_text_color=None, footer_background_color=None, footer_border_color=None, max_width='18rem')[source]

Add a section title to the page

Parameters:
  • background_color (str | None) – The name of the background color for the whole card

  • border_color (str | None) – The name of the border color for the whole card

  • image (str | None) – A header image for the card. The source image will not be deleted!

  • header_text (str | None) – Text to be shown as header of the card

  • header_text_color (str | None) – The name of the header text color

  • header_background_color (str | None) – The name of the background color for the header section

  • header_border_color (str | None) – The name of the border color for the header section, only really

  • footer_text (str | None) – Text to be shown as footer of the card

  • footer_text_color (str | None) – The name of the footer text color

  • footer_background_color (str | None) – The name of the background color for the footer section

  • footer_border_color (str | None) – The name of the border color for the footer section, only really affects the line between the footer and the body

  • max_width (str) – The maximum width of the card

add_column()[source]

Add a new column

add_custom_html_code(html)[source]

Add your own html code to the page

Parameters:

html (str) – Whatever you want to add

add_dictionary(dictionary, key_color=None, key_width=None, value_color=None)[source]

Add a dictionary as key value list to the report

Parameters:
  • dictionary (dict[str, str] | list[list[str]]) – The dictionary that should be added to the report. The key will be right aligned in one column, whereas the values will be left aligned in the next column. If you pass a list make sure it is a list of lists with 2 elements. The first will be assumed to be the key the second represents the value

  • key_color (str | None) – The text color for the keys

  • key_width (str | None) – The width of the key column. Use any of the html specifications, e.g. 150px etc.

  • value_color (str | None) – The color of the value text

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 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.

add_navbar_item(name)[source]

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, include_created_at=True, color=None)[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

  • include_created_at (bool) – Include a subheader with the exact creation time of the report

  • color (Optional[str]) – Background color of header

add_section_title(title_text, text_color=None, bar_color=None, alignment=None)[source]

Add a section title to the page

Parameters:
  • title_text (str) – Title text

  • text_color (Optional[str]) – Color of the title text

  • bar_color (Optional[str]) – Color of the bars

  • alignment (Optional[str]) – Alignment of the title. If left or right is chosen the bar will be omitted on the chosen side

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_data can either be a pandas DataFrame or 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 rows

    • search - Add a search field

    • no_sort - Disable initial sorting

    • color_negative_values - Highlight values < 0 in red

    • color_positive_values - Highlight values > 0 in green

    • full_width - Table spans full window width

  • size (Optional[int]) – Sets the width of the table (1-12). 12 uses 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_accordion()[source]

Close current accordion environment

close_cards()[source]

Close current cards environment

close_columns()[source]

Close current columns environment

close_navbar()[source]

Close current navbar environment

close_sublevel()[source]

Close current sub level environment

close_tabs()[source]

Close current tabs environment

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_cards(cards_type)[source]

Open a new cards environment

Parameters:

cards_type (Literal['group', 'deck', 'columns']) – Define the layout of how cards are grouped together

open_columns()[source]

Open a new columns environment

open_navbar(loc=None, color=None)[source]

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

open_sublevel(size=None, align=None)[source]

Opens a sub level environment

Parameters:
  • size (Optional[int]) – Controls the width of the sublevel, 1-12

  • align (Optional[str]) – Align things left, right or center

open_tabs()[source]

Open a tabs environment