-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
**Problem Statement** Default option `table` provides pretty output in console using styles (colors, etc..) but when we save it into a file using `--fileoutput` styles will not be passed. If we share the output file to others via s3 or something, styles will be missed and looks plain. It would be nice to keep the styles when rendering from the file. **Solution** Default option `table` using `Rich` library and same library has function `export_html` to generate html from table output. It will keep the same styles used in default table formatter.
- Loading branch information
1 parent
7cc6861
commit b25e2ec
Showing
4 changed files
with
22 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
from .table import table | ||
from .yaml import yaml | ||
from .csv import csv | ||
from .html import html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from rich.console import Console | ||
|
||
from robusta_krr.core.abstract import formatters | ||
from robusta_krr.core.models.result import Result | ||
from .table import table | ||
|
||
@formatters.register("html") | ||
def html(result: Result) -> str: | ||
console = Console(record=True) | ||
table_output = table(result) | ||
console.print(table_output) | ||
return console.export_html(inline_styles=True) |