simple_report.utils module

class simple_report.utils.ColorMap(config)[source]

Bases: object

Color map object for handling the color space of the report

Parameters:

config (dict[str, Any])

get_default_color(field, color_mode)[source]

Determine the correct default color for a given color mode and field

Parameters:
  • field (str) – The type/field the color should be used for

  • color_mode (str) – The color mode of the report, i.e., either light or dark

Returns:

str - The color to be used

Return type:

str

get_site_colors(color_mode)[source]

Get the background color for the website depending on the color mode

Parameters:

color_mode (str)

verify_and_get_color(color)[source]

Check that the requested color is actually available

Parameters:

color (str) – Color to check

Returns:

str - color name to use

Return type:

str

simple_report.utils.coerce_to_date(date)[source]

Coerce random data formats to a datetime.date object

Parameters:

date (Union[str, int, datetime.date, datetime.datetime]) – The date to coerce

Returns:

datetime.date - The coerce date object

Return type:

date

simple_report.utils.default(var, default)[source]

Helper function to check kwargs and set them to a default

You could simply use var or default. But for future additions we will use a separat function here :param var: The input variable :type var: Any :param default: Default value for the variable :type default: Any

Returns

Any - Either the variable itself, or the default value if var is None

Parameters:
  • var (Any)

  • default (Any)

Return type:

Any

simple_report.utils.verify_alignment(align)[source]

Check that the requested alignment is actually available

Parameters:

align (str) – The alignment tag that needs to be verified

Returns:

str - The alignment if it is acceptable

Return type:

str

simple_report.utils.verify_color_mode(color_mode)[source]

Check that the requested alignment is actually available

Parameters:

color_mode (str) – The alignment tag that needs to be verified

Returns:

str - The alignment if it is acceptable

Return type:

str