当前位置: 首页>>代码示例>>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;未经允许,请勿转载。