idmtools.utils.display.displays module#
Tools around displays and formatting.
Copyright 2021, Bill & Melinda Gates Foundation. All rights reserved.
- class idmtools.utils.display.displays.IDisplaySetting(header: str | None = None, field: str | None = None)[source]#
Bases:
object
Base class for a display setting.
The child class needs to implement the
display()
method.Includes:
header: Optional header for the display.
field: If specified, the
get_object()
will callgetattr
for this field on the object.
- __init__(header: str | None = None, field: str | None = None)[source]#
Initialize our IDisplaySetting.
- Parameters:
header – Header for display
field – Optional field to display instead of object
- get_object(obj: Any) Any [source]#
Get object or field depending if field is set.
- Parameters:
obj – Object to get
- Returns:
Either obj.field or obj depending if self.field is set
- abstract display(obj: Any) str [source]#
Display the object.
Note that the attribute (identified by self.field) should be handled with
get_object()
.- Parameters:
obj – The object to consider for display.
- Returns:
A string representing what to show.
- class idmtools.utils.display.displays.StringDisplaySetting(header: str | None = None, field: str | None = None)[source]#
Bases:
IDisplaySetting
Class that displays the object as string.
- class idmtools.utils.display.displays.DictDisplaySetting(header: str | None = None, field: str | None = None, max_items: int = 10, flat: bool = False)[source]#
Bases:
IDisplaySetting
Class that displays a dictionary.
- __init__(header: str | None = None, field: str | None = None, max_items: int = 10, flat: bool = False)[source]#
DictDisplay.
- Parameters:
header – Optional field header.
field – The field in the object to consider.
max_items – The maximum number of items to display.
flat – If False, display as a list; if True, display as a comma-separated list.
- class idmtools.utils.display.displays.TableDisplay(columns, max_rows=5, field=None)[source]#
Bases:
IDisplaySetting
Class that displays the object as a table.