Richclient
Classes¶
CLITheme ¶
Class to define styles for Rich widgets and prints in the CLI.
Functions¶
setup_rich_logger ¶
setup_rich_logger(
module_name=None,
logger_name=None,
logger_level=None,
verbose=False,
console=None,
)
Factory method to set logger with RichHandler.
The function is a copy of the method in rucio.common.utils setup_logger() with minor changes.
PARAMETER | DESCRIPTION |
---|---|
module_name
|
name of the module that is calling this method
TYPE:
|
logger_name
|
name of the logger, typically name of the module.
TYPE:
|
logger_level
|
if not given, fetched from config.
TYPE:
|
verbose
|
verbose option set in bin/rucio
TYPE:
|
console
|
Rich console object
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Logger
|
logger with RichHandler |
generate_table ¶
generate_table(
rows,
headers=None,
row_styles=None,
col_alignments=None,
table_format=CLITheme.TABLE_FMT,
)
Generates a Rich Table object from given input rows.
The elements in each row can be either plain strings or Rich renderable objects. Passing strings will display them as simple text, while using Rich objects allows you to introduce additional structure, styling, and widgets (e.g. Text, Trees) into the table. Strings with style markup will be rendered as styled text.
PARAMETER | DESCRIPTION |
---|---|
table_format
|
style of the table
TYPE:
|
headers
|
list of headers
TYPE:
|
rows
|
list of rows
TYPE:
|
col_alignments
|
list of column alignments
TYPE:
|
row_styles
|
list of row styles
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Table
|
a Rich Table object |
print_output ¶
print_output(*output, console, no_pager=False)
Prints the objects using the specified Rich console object. Optionally disables the pager if specified.
The function works similarly to Rich's console.print()
method but provides additional control over the pager feature.
PARAMETER | DESCRIPTION |
---|---|
output
|
objects to print to the terminal
TYPE:
|
console
|
Rich console object
TYPE:
|
no_pager
|
flag to disable the pager
TYPE:
|
get_cli_config ¶
get_cli_config()
Returns the CLI type from the config file.
RETURNS | DESCRIPTION |
---|---|
str
|
CLI type (Rich or tabulate) |
get_pager ¶
get_pager()
Returns the pager function based on the terminal availability.
RETURNS | DESCRIPTION |
---|---|
Callable[[str], None]
|
pager |