Render¶
render
¶
Classes:
| Name | Description |
|---|---|
OopsError |
Fatal error raised by oops commands. |
Functions:
| Name | Description |
|---|---|
format_datetime |
Format a datetime as a string using the configured datetime format. |
human_readable |
Convert a value to a human-readable string. |
print_error |
Print a styled error message to the terminal in red. |
print_rule |
Print a styled section banner to the terminal. |
print_success |
Print a styled success message to the terminal in green. |
print_warning |
Print a styled warning message to the terminal in yellow. |
render_boolean |
Render a boolean as a check symbol or an empty string. |
render_maintainers |
Render maintainer GitHub avatars as inline HTML image links. |
render_markdown_table |
Render a plain Markdown table from a header row and data rows. |
render_table |
Render a list of rows as a GitHub-flavoured Markdown table. |
sanitize_cell |
Collapse internal whitespace in a table cell value. |
OopsError
¶
flowchart TD
oops.utils.render.OopsError[OopsError]
click oops.utils.render.OopsError href "" "oops.utils.render.OopsError"
Fatal error raised by oops commands.
Renders as ✘ <message> in red on stderr (matching print_error's
visual style) and exits with code 1 via Click's standard exception flow,
so OopsCommand telemetry records it as Exit(1).
Use this for runtime errors that should terminate the command. For bad
user input prefer click.UsageError; for explicit non-error exits
prefer click.exceptions.Exit(N).
format_datetime
¶
human_readable
¶
Convert a value to a human-readable string.
Booleans become yes/no; collections are joined; strings are optionally
truncated to a maximum width.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Any
|
Value to render. |
required |
|
str
|
Separator used to join collection items. Defaults to ", ". |
', '
|
|
Optional[int]
|
If provided, truncate the result to this many characters. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Human-readable string representation of raw. |
Source code in src/oops/utils/render.py
print_error
¶
print_rule
¶
print_success
¶
print_warning
¶
render_boolean
¶
render_maintainers
¶
Render maintainer GitHub avatars as inline HTML image links.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
dict
|
Odoo manifest dict containing an optional "maintainers" list of GitHub usernames. |
required |
Returns:
| Type | Description |
|---|---|
str
|
HTML string of circular avatar |
str
|
or an empty string if no maintainers are listed. |
Source code in src/oops/utils/render.py
render_markdown_table
¶
Render a plain Markdown table from a header row and data rows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
List[str]
|
List of column header strings. |
required |
|
List[List[str]]
|
List of rows, where each row is a list of cell strings. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Markdown table string with a separator row after the header. |
Source code in src/oops/utils/render.py
render_table
¶
render_table(rows: List[List[Any]], headers: Optional[List[str]] = None, index: bool = False, start_index: int = 1) -> str
Render a list of rows as a GitHub-flavoured Markdown table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
List[List[Any]]
|
List of row data, where each row is a list of cell values. |
required |
|
Optional[List[str]]
|
Optional column header labels. |
None
|
|
bool
|
If True, prepend a numeric row index. Defaults to False. |
False
|
|
int
|
First index value when index is True. Defaults to 1. |
1
|
Returns:
| Type | Description |
|---|---|
str
|
Formatted Markdown table string. |
Source code in src/oops/utils/render.py
sanitize_cell
¶
Collapse internal whitespace in a table cell value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Any
|
Raw cell value string. |
required |
Returns:
| Type | Description |
|---|---|
str
|
String with runs of whitespace replaced by a single space, |
str
|
or an empty string if s is falsy. |