rich
rich_print_to_string(objs)
¶
Convert a rich console print output to a string.
Source code in src/slack_helpers/utils/rich.py
rich_print_to_html(objs, backend='ansi2html')
¶
Convert a rich console print output to an html string.
rich backend can be prettier with the following caveats:
1. It produces a larger file size (2x)
2. It isn't as easy to read as a plain HTML code due to alignment and many html tags.
3. Slack doesn't understand the HTML code produced by console.export_html()
and treat it as a binary file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
objs |
Iterable[Any] | Any
|
The objects to print. Possibly but not limited to rich objects. |
required |
backend |
Literal['ansi2html', 'rich']
|
"ansi2html" or "rich". Defaults to "ansi2html". |
'ansi2html'
|
Source code in src/slack_helpers/utils/rich.py
rich_print_to_svg(objs, title)
¶
Convert a rich console print to an svg string.
Source code in src/slack_helpers/utils/rich.py
rich_traceback_to_string(tb)
¶
Convert a rich traceback to a string.
Examples:
>>> try:
... 1 / 0
... except ZeroDivisionError:
... import rich.traceback
... tb = rich.traceback.Traceback()
... print(rich_traceback_to_string(tb))
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
...
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ZeroDivisionError: division by zero
Source code in src/slack_helpers/utils/rich.py
rich_traceback_to_html(tb, backend='ansi2html')
¶
Convert a rich traceback to an html string.
Examples:
>>> try:
... 1 / 0
... except ZeroDivisionError:
... import rich.traceback
... tb = rich.traceback.Traceback()
... print(rich_traceback_to_html(tb))
<!DOCTYPE HTML ...
</html>
Source code in src/slack_helpers/utils/rich.py
rich_traceback_to_svg(tb, title)
¶
Convert a rich traceback to an svg string.
Examples:
>>> try:
... 1 / 0
... except ZeroDivisionError:
... import rich.traceback
... tb = rich.traceback.Traceback()
... print(rich_traceback_to_svg(tb, "title"))
<svg class="rich-terminal" ...
</svg>