How to use the prettytable.ALL function in prettytable

To help you get started, we’ve selected a few prettytable 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 kxxoling / PTable / tests / test_prettytable.py View on Github external
def setUp(self):
        BasicTests.setUp(self)
        self.x.hrules = ALL
github aquasecurity / kube-hunter / kube_hunter / modules / report / plain.py View on Github external
def services_table(self):
        services_table = PrettyTable(["Service", "Location", "Description"], hrules=ALL)
        services_table.align = "l"
        services_table.max_width = MAX_TABLE_WIDTH
        services_table.padding_width = 1
        services_table.sortby = "Service"
        services_table.reversesort = True
        services_table.header_style = "upper"
        with services_lock:
            for service in services:
                services_table.add_row(
                    [service.get_name(), f"{service.host}:{service.port}{service.get_path()}", service.explain()]
                )
            detected_services_ret = f"\nDetected Services\n{services_table}\n"
        return detected_services_ret
github embedded-sec / BenchIoT / os-lib / mbed-os / tools / export / __init__.py View on Github external
for target in sorted(TARGET_NAMES):
        row = [target]  # First column is platform name
        for ide in supported_ides:
            text = "-"
            if EXPORTERS[ide].is_target_supported(target):
                if verbose_html:
                    text = "✓"
                else:
                    text = "x"
                perm_counter += 1
            row.append(text)
        table_printer.add_row(row)

    table_printer.border = True
    table_printer.vrules = ALL
    table_printer.hrules = ALL
    # creates a html page in a shorter format suitable for readme.md
    if verbose_html:
        result = table_printer.get_html_string()
    else:
        result = table_printer.get_string()
    result += "\n"
    result += "Total IDEs: %d\n"% (len(supported_ides))
    if verbose_html:
        result += "<br>"
    result += "Total platforms: %d\n"% (len(TARGET_NAMES))
    if verbose_html:
        result += "<br>"
    result += "Total permutations: %d"% (perm_counter)
    if verbose_html:
        result = result.replace("&amp;", "&amp;")
    return result
github anchore / anchore-cli / anchorecli / cli / utils.py View on Github external
def _format_triggers(payload, gate, all=False):
    try:
        if not all:
            header = ['Trigger', 'Description', 'Parameters']
        else:
            header = ['Trigger', 'Description', 'Parameters', 'State', 'Superceded By']
        t = PrettyTable(header, hrules=ALL)
        t.align = 'l'

        if payload:
            for gate in [x for x in payload if x['name'].lower() == gate]:
                for trigger_entry in gate.get('triggers', []):
                    desc = string_splitter(trigger_entry.get('description', ''))
                    param_str = string_splitter(', '.join([x['name'].lower() for x in trigger_entry.get('parameters', [])]), max_length=20)
                    if all:
                        t.add_row([trigger_entry['name'].lower(), desc, param_str, trigger_entry.get('state', ''), trigger_entry.get('superceded_by', '')])
                    elif trigger_entry.get('state') in [None, 'active']:
                        t.add_row([trigger_entry['name'].lower(), desc, param_str])

            return t.get_string(sortby='Trigger', print_empty=True)
        else:
            return 'No policy spec to parse'
github FedoraKDE / fedora-kde-frameworks / scripts / update-kf5.py View on Github external
if not args.no_update:
            pkg.updateSpec()

        scanner = DependencyScanner(pkg)
        if scanner.load():
            pkg.scanner = scanner
        else:
            pkg.scanner = None

        pkgs.append(pkg)
        print('Done')


    table = PrettyTable(['Package', 'Old Version', 'New Version', 'Added deps', 'Removed deps', 'Added devel deps', 'Removed devel deps'])
    table.align = 'l'
    table.hrules = ALL
    for pkg in pkgs:
        table.add_row([pkg.name,
                      "%s-%s" % (pkg.rawVersion, pkg.rawRelease),
                      "%s-%s" % (pkg.newVersion, pkg.newRelease),
                      '\n'.join(list(map(lambda x : x.name(), pkg.scanner.depsAdd))) if pkg.scanner else "[error]",
                      '\n'.join(list(map(lambda x : x.name(), pkg.scanner.depsRemove))) if pkg.scanner else "[error]",
                      '\n'.join(list(map(lambda x : x.name(), pkg.scanner.develDepsAdd))) if pkg.scanner else "[error]",
                      '\n'.join(list(map(lambda x : x.name(), pkg.scanner.develDepsRemove))) if pkg.scanner else "[error]"])
    print(table.get_string(sortby='Package'))

    proceed = input("Proceed? [Y/n] ")
    if proceed.lower() == 'n':
        return

    for pkg in pkgs:
        print(pkg.name)
github marten-seemann / quic-network-simulator / interop / run.py View on Github external
def _print_results(self):
    """print the interop table"""
    def get_letters(testcases):
      if len(testcases) == 0:
        return "-"
      return "".join([ test.abbreviation() for test in testcases ])
      
    t = prettytable.PrettyTable()
    t.hrules = prettytable.ALL
    t.vrules = prettytable.ALL
    t.field_names = [ "" ] + [ name for name in self._servers ]
    for client in self._clients:
      row = [ client ]
      for server in self._servers:
        cell = self.results[server][client]
        res = colored(get_letters(cell[TestResult.SUCCEEDED]), "green") + "\n"
        res += colored(get_letters(cell[TestResult.UNSUPPORTED]), "yellow") + "\n"
        res += colored(get_letters(cell[TestResult.FAILED]), "red")
        row += [ res ]
      t.add_row(row)
    print(t)
github modera / mcloud / mcloud / rpc_client.py View on Github external
app_config = yield self._remote_exec('config', app)

        parser_env = set_env or app_config['env']

        if diff or (not update and not set_env):
            old_config = YamlConfig(source=unicode(app_config['source']), app_name=app, env=parser_env)
            old_config.load(process=False)
            from collections import OrderedDict

            yaml.add_representer(unicode, yaml.representer.SafeRepresenter.represent_unicode)
            yaml.add_representer(OrderedDict, self.represent_ordereddict)
            olds = yaml.dump(old_config.config, default_flow_style=False)

        if not update and not diff and not set_env:
            x = PrettyTable(["Name", "Value"], hrules=ALL, align='l', header=False)
            x.align = "l"
            x.add_row(['Config', olds])
            x.add_row(['Environment', app_config['env']])
            x.add_row(['Path', app_config['path']])
            print(x)

        else:
            if config:
                config_file = os.path.expanduser(config)
            else:
                config_file = 'mcloud.yml'

            new_config = YamlConfig(file=config_file, app_name=app, env=parser_env)
            new_config.load(process=False)

            if diff:
github raimon49 / pip-licenses / piplicenses.py View on Github external
def factory_styled_table_with_args(args, output_fields=DEFAULT_OUTPUT_FIELDS):
    table = PrettyTable()
    table.field_names = output_fields
    table.align = 'l'
    table.border = (args.format == 'markdown' or args.format == 'rst' or
                    args.format == 'confluence' or args.format == 'json')
    table.header = True

    if args.format == 'markdown':
        table.junction_char = '|'
        table.hrules = RULE_HEADER
    elif args.format == 'rst':
        table.junction_char = '+'
        table.hrules = RULE_ALL
    elif args.format == 'confluence':
        table.junction_char = '|'
        table.hrules = RULE_NONE
    elif args.format == 'json':
        table = JsonPrettyTable(table.field_names)
    elif args.format == 'json-license-finder':
        table = JsonLicenseFinderTable(table.field_names)
    elif args.format == 'csv':
        table = CSVPrettyTable(table.field_names)
    elif args.format == 'plain-vertical':
        table = PlainVerticalTable(table.field_names)

    return table
github openstack / governance / tools / check_review_status.py View on Github external
status = sorted(
        (get_one_status(change, delegates, tc_members)
         for change in all_changes()),
        key=operator.itemgetter('URL'),
    )

    columns = (
        'Summary',
        'Status',
        'Votes',
        'Members',
    )

    x = prettytable.PrettyTable(
        field_names=columns,
        hrules=prettytable.ALL,
    )
    x.align['Summary'] = 'l'
    x.align['Status'] = 'l'
    x.align['Votes'] = 'l'
    x.align['Members'] = 'l'
    for row in status:
        x.add_row([row[c] for c in columns])
    print(x.get_string())
github aquasecurity / kube-hunter / kube_hunter / modules / report / plain.py View on Github external
def hunters_table(self):
        column_names = ["Name", "Description", "Vulnerabilities"]
        hunters_table = PrettyTable(column_names, hrules=ALL)
        hunters_table.align = "l"
        hunters_table.max_width = MAX_TABLE_WIDTH
        hunters_table.sortby = "Name"
        hunters_table.reversesort = True
        hunters_table.padding_width = 1
        hunters_table.header_style = "upper"

        hunter_statistics = self.get_hunter_statistics()
        for item in hunter_statistics:
            hunters_table.add_row([item.get("name"), item.get("description"), item.get("vulnerabilities")])
        return f"\nHunter Statistics\n{hunters_table}\n"