Skip to content

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.

:param module_name: name of the module that is calling this method :param logger_name: name of the logger, typically name of the module. :param logger_level: if not given, fetched from config. :param verbose: verbose option set in bin/rucio :param console: Rich console object :returns: 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.

:param table_format: style of the table :param headers: list of headers :param rows: list of rows :param col_alignments: list of column alignments :param row_styles: list of row styles :returns: 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.

:param output: objects to print to the terminal :param console: Rich console object :param no_pager: flag to disable the pager

get_cli_config

get_cli_config()

Returns the CLI type from the config file.

:returns: CLI type (Rich or tabulate)

get_pager

get_pager()

Returns the pager function based on the terminal availability.

:returns: pager