當前位置: 首頁>>代碼示例>>Python>>正文


Python prettytable.ALL屬性代碼示例

本文整理匯總了Python中prettytable.ALL屬性的典型用法代碼示例。如果您正苦於以下問題:Python prettytable.ALL屬性的具體用法?Python prettytable.ALL怎麽用?Python prettytable.ALL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在prettytable的用法示例。


在下文中一共展示了prettytable.ALL屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: upgrade_check

# 需要導入模塊: import prettytable [as 別名]
# 或者: from prettytable import ALL [as 別名]
def upgrade_check(self):
        check_results = []

        t = prettytable.PrettyTable(['Upgrade Check Results'],
                                    hrules=prettytable.ALL)
        t.align = 'l'

        for name, method in self.check_methods.items():
            result = method()
            check_results.append(result)
            cell = (
                'Check: %(name)s\n'
                'Result: %(result)s\n'
                'Details: %(details)s' %
                {
                    'name': name,
                    'result': UPGRADE_CHECK_MSG_MAP[result.code],
                    'details': result.get_details(),
                }
            )
            t.add_row([cell])
        print(t)

        return max(res.code for res in check_results) 
開發者ID:openstack,項目名稱:kuryr-kubernetes,代碼行數:26,代碼來源:status.py

示例2: _format_gates

# 需要導入模塊: import prettytable [as 別名]
# 或者: from prettytable import ALL [as 別名]
def _format_gates(payload, all=False):
    if not all:
        header = ['Gate', 'Description']
    else:
        header = ['Gate', 'Description', 'State', 'Superceded By']

    t = PrettyTable(header, hrules=ALL)
    t.align = 'l'

    if payload:
        for gate in payload:
            desc = string_splitter(gate.get('description', ''), 60)
            if all:
                t.add_row([gate['name'].lower(), desc, gate.get('state', ''), gate.get('superceded_by', '')])
            elif gate.get('state') in [None, 'active']:
                t.add_row([gate['name'].lower(), desc])

        return t.get_string(sortby='Gate', print_empty=True)
    else:
        return  'No policy spec to parse' 
開發者ID:anchore,項目名稱:anchore-cli,代碼行數:22,代碼來源:utils.py

示例3: _format_triggers

# 需要導入模塊: import prettytable [as 別名]
# 或者: from prettytable import ALL [as 別名]
def _format_triggers(payload, gate, all=False):
    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' 
開發者ID:anchore,項目名稱:anchore-cli,代碼行數:23,代碼來源:utils.py

示例4: _format_trigger_params

# 需要導入模塊: import prettytable [as 別名]
# 或者: from prettytable import ALL [as 別名]
def _format_trigger_params(payload, gate, trigger, all=False):
    if all:
        header = ['Parameter', 'Description', 'Required', 'Example', 'State', 'Supereceded By']
    else:
        header = ['Parameter', 'Description', 'Required', 'Example']
    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 [x for x in gate.get('triggers', []) if x['name'].lower() == trigger]:
                for p in trigger_entry.get('parameters', []):
                    desc = string_splitter(p.get('description', ''))
                    if all:
                        t.add_row([p['name'].lower(), desc, p.get('required', True), p.get('example',''), p.get('state', ''), p.get('superceded_by', '')])
                    elif p.get('state') in [None, 'active']:
                        t.add_row([p['name'].lower(), desc, p.get('required', True), p.get('example', '')])


        return t.get_string(sortby='Parameter', print_empty=True)
    else:
        return 'No policy spec to parse' 
開發者ID:anchore,項目名稱:anchore-cli,代碼行數:24,代碼來源:utils.py

示例5: render_table

# 需要導入模塊: import prettytable [as 別名]
# 或者: from prettytable import ALL [as 別名]
def render_table(data, header=None, include_ind=True, drop_cols: set = None):
    if not drop_cols:
        drop_cols = set()

    for d in data:
        for k in list(d):
            if k in drop_cols:
                del d[k]

    # set up simple table to iterate through response
    table = PrettyTable(hrules=prettytable.ALL)
    if header:
        table.title = header
    out = list(data)

    if include_ind:
        table.field_names = ['ind'] + list(out[0].keys())
        for ind, d in enumerate(out):
            table.add_row([ind] + list(d.values()))
    else:
        table.field_names = list(out[0].keys())
        for d in out:
            table.add_row(list(d.values()))
    return table.get_string() 
開發者ID:KI-labs,項目名稱:kaos,代碼行數:26,代碼來源:rendering.py

示例6: nodes_table

# 需要導入模塊: import prettytable [as 別名]
# 或者: from prettytable import ALL [as 別名]
def nodes_table(self):
        nodes_table = PrettyTable(["Type", "Location"], hrules=ALL)
        nodes_table.align = "l"
        nodes_table.max_width = MAX_TABLE_WIDTH
        nodes_table.padding_width = 1
        nodes_table.sortby = "Type"
        nodes_table.reversesort = True
        nodes_table.header_style = "upper"
        id_memory = set()
        services_lock.acquire()
        for service in services:
            if service.event_id not in id_memory:
                nodes_table.add_row(["Node/Master", service.host])
                id_memory.add(service.event_id)
        nodes_ret = "\nNodes\n{}\n".format(nodes_table)
        services_lock.release()
        return nodes_ret 
開發者ID:aquasecurity,項目名稱:kube-hunter,代碼行數:19,代碼來源:plain.py

示例7: table

# 需要導入模塊: import prettytable [as 別名]
# 或者: from prettytable import ALL [as 別名]
def table(self):
        x = pt.PrettyTable(align = 'r', float_format = '1.3', hrules = pt.ALL)
        x.add_column("objval", self._objvals.tolist())
        x.add_column("solution", list(map(self.solution_string, self._solutions)))
        return str(x) 
開發者ID:ustunb,項目名稱:risk-slim,代碼行數:7,代碼來源:solution_classes.py

示例8: format_table

# 需要導入模塊: import prettytable [as 別名]
# 或者: from prettytable import ALL [as 別名]
def format_table(table, hrules=False, align="l"):
    if not hrules:
        hrules = prettytable.FRAME
    else:
        hrules = prettytable.ALL

    header = [click.style(x, fg="red", bold=True) for x in table[0]]
    t = prettytable.PrettyTable(header, hrules=hrules)
    t.align = align
    for index, row in enumerate(table[1:]):
        row = [str(x) for x in row]
        row[0] = click.style(row[0], fg="yellow")
        t.add_row(row)
    return t 
開發者ID:bitshares,項目名稱:uptick,代碼行數:16,代碼來源:ui.py

示例9: create_sub_report

# 需要導入模塊: import prettytable [as 別名]
# 或者: from prettytable import ALL [as 別名]
def create_sub_report(ip):
    # create HX controller report file
    global subreportfiles
    filename = "HX_Report_" + str(ip) +".txt"
    subreportfiles.append(filename)
    with open(filename, "w") as fh:
        fh.write("\t\t\t     HX Health Check " + str(toolversion))
        fh.write("\r\n")
        fh.write("\t\t\tHX Controller: " + ip)
        fh.write("\r\n")
        fh.write("\t\t\tHX Hostname: " + hostd[ip].get("hostname", ""))
        fh.write("\r\n")
        fh.write("#" * 80)
        fh.write("\r\n")
        n = 1
        for cname in testdetail[ip].keys():
            fh.write("\r\n" + str(n) + ") " + cname + ":")
            fh.write("\r\n")
            tw = PrettyTable(hrules=ALL)
            tw.field_names = ["Name", "Status", "Comments"]
            tw.align = "l"
            for k, v in testdetail[ip][cname].items():
                if type(v) == list:
                    tw.add_row([k, "\n".join(v), ""])
                elif type(v) == dict:
                    tw.add_row([k, v["Status"], v["Result"]])
                else:
                    tw.add_row([k, v, ""])
            fh.write((str(tw)).replace("\n", "\r\n"))
            fh.write("\r\n")
            n += 1

    #print("\r\nSub Report File: " + filename)
    log_msg(INFO, "Sub Report File: " + filename + "\r") 
開發者ID:CiscoDevNet,項目名稱:Hyperflex-Hypercheck,代碼行數:36,代碼來源:HXTool.py

示例10: print_permissions

# 需要導入模塊: import prettytable [as 別名]
# 或者: from prettytable import ALL [as 別名]
def print_permissions(account):
    t = PrettyTable(["Permission", "Threshold", "Key/Account"], hrules=allBorders)
    t.align = "r"
    for permission in ["owner", "active", "posting"]:
        auths = []
        for type_ in ["account_auths", "key_auths"]:
            for authority in account[permission][type_]:
                auths.append("%s (%d)" % (authority[0], authority[1]))
        t.add_row([
            permission,
            account[permission]["weight_threshold"],
            "\n".join(auths),
        ])
    print(t) 
開發者ID:xeroc,項目名稱:piston-cli,代碼行數:16,代碼來源:ui.py

示例11: _mk_tbl

# 需要導入模塊: import prettytable [as 別名]
# 或者: from prettytable import ALL [as 別名]
def _mk_tbl(fields):
    tbl = prettytable.PrettyTable(fields, left_padding_width=1, right_padding_width=1, hrules=prettytable.ALL)
    col_max_width = (terminalsize()[0] / len(fields)) - 5

    for k in tbl.align:
        tbl.align[k] = 'l'

    return (tbl, col_max_width) 
開發者ID:SafeBreach-Labs,項目名稱:pacdoor,代碼行數:10,代碼來源:dns_cnc_srv.py

示例12: main

# 需要導入模塊: import prettytable [as 別名]
# 或者: from prettytable import ALL [as 別名]
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('module', nargs='?',
                        default='callback_plugins.baseline')
    parser.add_argument('--rst', action='store_true')
    args = parser.parse_args()

    if args.rst:
        br = '\n| '
        start = '| '
    else:
        br = '<br>'
        start = ''

    try:
        module = importlib.import_module(args.module)
    except ImportError as e:
        raise SystemExit('Could not import %s: %s' % (args.module, e))
    doc = yaml.safe_load(module.DOCUMENTATION)
    x = prettytable.PrettyTable(
        ['Parameter', 'Choices/Defaults', 'Configuration', 'Comments']
    )
    for k in x.align:
        x.align[k] = 'l'

    options = doc.get('options', {})
    for name, data in sorted(options.items(), key=lambda t: t[0]):
        x.add_row([normalize(i, rst=args.rst) for i in (
            param(name, data, br=br, start=start),
            default(data),
            config(data, br=br, start=start),
            data['description']
        )])

    if args.rst:
        lines = x.get_string(hrules=prettytable.ALL).splitlines()
        lines[2] = lines[2].replace('-', '=')
        print('\n'.join(lines))
    else:
        print('\n'.join(x.get_string(junction_char='|').splitlines()[1:-1])) 
開發者ID:ansible,項目名稱:ansible-baseline,代碼行數:42,代碼來源:document_callback.py

示例13: print_output

# 需要導入模塊: import prettytable [as 別名]
# 或者: from prettytable import ALL [as 別名]
def print_output(columns, rows, alignment=None, fmt='pretty', header=None, delimiter='\t'):
    if fmt in {'json', 'yaml', 'yml'}:
        elements = [{k: v for k, v in zip(columns, r) if not header or str(v)} for r in rows]
        func = json.dumps if fmt == 'json' else format_config_for_editing
        click.echo(func(elements))
    elif fmt in {'pretty', 'tsv', 'topology'}:
        list_cluster = bool(header and columns and columns[0] == 'Cluster')
        if list_cluster and 'Tags' in columns:  # we want to format member tags as YAML
            i = columns.index('Tags')
            for row in rows:
                if row[i]:
                    row[i] = format_config_for_editing(row[i], fmt != 'pretty').strip()
        if list_cluster and fmt != 'tsv':  # skip cluster name if pretty-printing
            columns = columns[1:] if columns else []
            rows = [row[1:] for row in rows]

        if fmt == 'tsv':
            for r in ([columns] if columns else []) + rows:
                click.echo(delimiter.join(map(str, r)))
        else:
            hrules = ALL if any(any(isinstance(c, six.string_types) and '\n' in c for c in r) for r in rows) else FRAME
            table = PatronictlPrettyTable(header, columns, hrules=hrules)
            for k, v in (alignment or {}).items():
                table.align[k] = v
            for r in rows:
                table.add_row(r)
            click.echo(table) 
開發者ID:zalando,項目名稱:patroni,代碼行數:29,代碼來源:ctl.py

示例14: render_job_info

# 需要導入模塊: import prettytable [as 別名]
# 或者: from prettytable import ALL [as 別名]
def render_job_info(data, sort_by):
    response = PagedResponse.from_dict(data)
    info = JobInfo.from_dict(response.response)
    page_id = response.page_id
    page_count = response.page_count
    # "global" (i.e. job) level info
    formatted_info = f"""
    Job ID: {info.job_id}
    Process time: {info.process_time}
    State: {info.state}
    Available metrics: {info.available_metrics}

    Page count: {page_count}
    Page ID: {page_id}"""
    table = PrettyTable(hrules=prettytable.ALL)
    header = ['ind', 'Code', 'Data', 'Model ID', 'Hyperparams']
    if sort_by:
        header.append('Score')
    table.field_names = header
    for ind, d in enumerate(info.partitions):
        code = d.code
        code_summary = f"Author: {code.author}\nPath: {code.path}"

        data = d.data
        data_summary = f"Author: {data.author}\nPath: {data.path}"

        hyper_summary = None
        if d.hyperparams:
            hyper = d.hyperparams
            hyper_summary = f"Author: {hyper.author}\nPath: {hyper.path}"

        output = d.output
        output_summary = f"{output.path}"
        row = [ind, code_summary, data_summary, output_summary, hyper_summary]
        if sort_by:
            row.append(d.score)
        table.add_row(row)
    formatted_info += "\n" + table.get_string()
    return formatted_info 
開發者ID:KI-labs,項目名稱:kaos,代碼行數:41,代碼來源:rendering.py

示例15: display_results

# 需要導入模塊: import prettytable [as 別名]
# 或者: from prettytable import ALL [as 別名]
def display_results(saved_credentials, pwned_passwords):
    
    if len(pwned_passwords) == 0:
        LOG.info("Good news - it looks like none of your Firefox saved password is pwned!")
        return

    table = prettytable.PrettyTable([
        COLOR_BOLD + 'Website' + COLOR_RESET,
        COLOR_BOLD + 'Username' + COLOR_RESET,
        COLOR_BOLD + 'Password' + COLOR_RESET,
        COLOR_BOLD + 'Status' + COLOR_RESET
    ], hrules=prettytable.ALL)

    for credential in saved_credentials:
        password = credential['password']
        if password in pwned_passwords:
            count = pwned_passwords[password]
            message = 'Pwned in %d breaches!' % count
            table.add_row([
                credential['url'],
                credential['username'],
                password,
                COLOR_RED + COLOR_BOLD + message + COLOR_RESET
            ])
    
    print(table) 
開發者ID:christophetd,項目名稱:firepwned,代碼行數:28,代碼來源:firepwned.py


注:本文中的prettytable.ALL屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。