How to use the rich.table.Table function in rich

To help you get started, we’ve selected a few rich examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ArturSpirin / test_junkie / test_junkie / cli / hq / hq.py View on Github external
def ls(display_tokens=False):

        if not os.path.exists(Config.get_hq_root_dir()):
            console.print("Resource not found.")
            exit(0)
        docs = os.listdir(Config.get_hq_root_dir())
        if docs:
            from rich.table import Table

            table = Table(title="")

            table.add_column("ID", justify="left", style="blue")
            table.add_column("Host")
            table.add_column("Name")
            if display_tokens:
                table.add_column("Token", justify="left", no_wrap=True)
            table.add_column("Status", justify="left")

            for doc in docs:
                with open(Config.get_hq_root_dir() + os.sep + doc, "r+") as details:
                    server = loads(details.read())
                    if display_tokens:
                        table.add_row(f"{server['id']}", f"{server['host']}", f"{server['name']}", f"{server['token']}")
                    else:
                        table.add_row(f"{server['id']}", f"{server['host']}", f"{server['name']}")
            console.print(table)
github ccev / stopwatcher / stop_watcher.py View on Github external
["delete_converted_stops", "Delete converted Stops"],
    ["send", "What to send notifications for"],
    ["send_empty", "Should they be sent with an unknown image/name?"],
    ["edits", "What to track edits for"],
    ["edit_types", "What kind of edits to track"],
    ["update_gym_title", "If a Portal's title changes, should the corresponding Gym title get updated?"]
]

config.console.log("Done. Ready to watch Stops")

for fil in config.filters:
    #print("----------------------------")
    #print(f"Going through {fil['area']}")
    #print("")
    config.console.log(f"[green]> Now going through [bold]{fil['area'].capitalize()}")
    table = Table(show_header=False)
    table.add_column("key")
    table.add_column("value")
    for logfilter in log_filters:
        value = fil.get(logfilter[0], None)
        if isinstance(value, list):
            value = ", ".join(value)
        table.add_row(logfilter[1], str(value))
    config.console.log(table)

    dont_send_empty = True
    if "send_empty" in fil:
        if fil["send_empty"]:
            dont_send_empty = False

    deleted_max_portals = 5
    deleted_timespan_portals = ((4*config.scraper_wait) / 60)
github intel / cve-bin-tool / cve_bin_tool / OutputEngine.py View on Github external
def output_console(self, console=Console()):
        """ Output list of CVEs in a tabular format with color support """

        # table instance
        table = Table()

        # Add Head Columns to the Table
        table.add_column("Vendor")
        table.add_column("Product")
        table.add_column("Version")
        table.add_column("CVE Number")
        table.add_column("Severity")

        # colors provide color name according to the severity
        colors = {"CRITICAL": "red", "HIGH": "blue", "MEDIUM": "yellow", "LOW": "green"}

        # Add CVEData to the table
        for cve_data in self.formatted_output:
            color = colors[cve_data["severity"]]
            table.add_row(
                f'[{color}]{cve_data["vendor"]} [/{color}]',
github foxmask / yeoboseyo / yeoboseyo / run.py View on Github external
async def report():
    triggers = await Trigger.objects.all()
    table = Table(show_header=True, header_style="bold magenta")
    table.add_column("ID")
    table.add_column("Name")
    table.add_column("Md Folder")
    table.add_column("Joplin Folder")
    table.add_column("Mastodon")
    table.add_column("Mail")
    table.add_column("Status")
    table.add_column("Triggered", style="dim")

    for trigger in triggers:
        status = "[green]Ok[/]" if trigger.status else "[yellow]Disabled[/]"
        masto = "[green]Ok[/]" if trigger.mastodon else "[yellow]Disabled[/]"
        mail = "[green]Ok[/]" if trigger.mail else "[yellow]Disabled[/]"
        date_triggered = trigger.date_triggered if trigger.date_triggered is not None else '***Not triggered yet**'
        joplin_folder = trigger.joplin_folder if trigger.joplin_folder is not None else '***Not used ***'
        localstorage = trigger.localstorage if trigger.localstorage is not None else '***Not used ***'