当前位置: 首页>>代码示例>>Python>>正文


Python tabulate.tabulate方法代码示例

本文整理汇总了Python中tabulate.tabulate方法的典型用法代码示例。如果您正苦于以下问题:Python tabulate.tabulate方法的具体用法?Python tabulate.tabulate怎么用?Python tabulate.tabulate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tabulate的用法示例。


在下文中一共展示了tabulate.tabulate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: do_agents

# 需要导入模块: import tabulate [as 别名]
# 或者: from tabulate import tabulate [as 别名]
def do_agents(self,args):
        """ list all agents in interacting """
        list_agents = []
        # get all session activated
        if self.settings['agents'].keys() != {}:
            for agent in self.settings['agents'].keys():
                if self.settings['agents'][agent]['tunel'] != None:
                    if self.settings['agents'][agent]['tunel'].activated:
                        list_agents.append([agent,self.settings['agents'][agent]['creds']['Host'],
                self.settings['agents'][agent]['creds']['Port'],
                    self.settings['agents'][agent]['tunel'].session.name,
                        self.settings['agents'][agent]['tunel'].session.pid])
            if list_agents != []:
                color.display_messages('Session Agents:', info=True, sublime=True)
                print tabulate(list_agents,headers=C.headersAgents)
                color.linefeed()
                return color.display_messages('Online Agents: {}'.format(color.setcolor(str(len(list_agents)),
                color='blue')), info=True)
        color.display_messages('No agents in interacting', info=True) 
开发者ID:mh4x0f,项目名称:b1tifi,代码行数:21,代码来源:console.py

示例2: format

# 需要导入模块: import tabulate [as 别名]
# 或者: from tabulate import tabulate [as 别名]
def format(self, findings):
        table = []
        for finding in findings:
            url = str(finding.url) if finding.url else ''
            severity = str(finding.severity.name) if finding.severity.name else ''
            header = str(finding.header) if finding.header else ""
            ftype = str(finding.ftype.name.lower()) if finding.ftype.name else ""
            directive = str(finding.directive) if finding.directive else ""
            value = str(finding.value) if finding.value else ""
            description = str(finding.description) if finding.description else ""
            f = finding
            if self.hascolor:
                color = self.getColor(finding.severity)
                endColor = '\033[0m'
            else:
                color = ''
                endColor = ''
            table.append([url, color + severity + endColor +"", header, ftype, directive, value, description])
        return str(tabulate(table, headers=["URL","Severity", "Header", "Finding Type", "Directive", "Value","Description"],tablefmt=self.tableformat)) 
开发者ID:koenbuyens,项目名称:securityheaders,代码行数:21,代码来源:findingformatterfactory.py

示例3: main

# 需要导入模块: import tabulate [as 别名]
# 或者: from tabulate import tabulate [as 别名]
def main():
  args = parser.parse_args()
  headers = ['filename', 'usWeightClass']
  rows = []
  for font in args.font:
    ttfont = ttLib.TTFont(font)
    rows.append([os.path.basename(font), ttfont['OS/2'].usWeightClass])

  def as_csv(rows):
    import csv
    import sys
    writer = csv.writer(sys.stdout)
    writer.writerows([headers])
    writer.writerows(rows)
    sys.exit(0)

  if args.csv:
    as_csv(rows)

  print(tabulate.tabulate(rows, headers, tablefmt="pipe")) 
开发者ID:googlefonts,项目名称:gftools,代码行数:22,代码来源:gftools-list-weightclass.py

示例4: printInfo

# 需要导入模块: import tabulate [as 别名]
# 或者: from tabulate import tabulate [as 别名]
def printInfo(fonts, print_csv=False):
  rows = []
  headers = ['filename', 'fsSelection']
  for font in fonts:
    ttfont = ttLib.TTFont(font)
    row = [os.path.basename(font)]
    row.append(('{:#010b} '
                '{:#010b}'
                '').format(getByte2(ttfont),
                           getByte1(ttfont)).replace('0b', ''))
    rows.append(row)

  def as_csv(rows):
    writer = csv.writer(sys.stdout)
    writer.writerows([headers])
    writer.writerows(rows)
    sys.exit(0)

  if print_csv:
    as_csv(rows)
  else:
    print(tabulate.tabulate(rows, headers, tablefmt="pipe")) 
开发者ID:googlefonts,项目名称:gftools,代码行数:24,代码来源:gftools-fix-fsselection.py

示例5: print_info

# 需要导入模块: import tabulate [as 别名]
# 或者: from tabulate import tabulate [as 别名]
def print_info(fonts, print_csv=False):
    headers = ['filename', 'usWidthClass']
    rows = []
    warnings = []
    for font in fonts:
        ttfont = ttLib.TTFont(font)
        usWidthClass = ttfont['OS/2'].usWidthClass
        rows.append([os.path.basename(font), usWidthClass])
        if usWidthClass != 5:
            warning = "WARNING: {} is {}, expected 5"
            warnings.append(warning.format(font, usWidthClass))

    def as_csv(rows):
        writer = csv.writer(sys.stdout)
        writer.writerows([headers])
        writer.writerows(rows)
        sys.exit(0)

    if print_csv:
        as_csv(rows)

    print(tabulate.tabulate(rows, headers, tablefmt="pipe"))
    for warn in warnings:
        print(warn, file=sys.stderr) 
开发者ID:googlefonts,项目名称:gftools,代码行数:26,代码来源:gftools-list-widthclass.py

示例6: fix

# 需要导入模块: import tabulate [as 别名]
# 或者: from tabulate import tabulate [as 别名]
def fix(fonts, value=None):
    rows = []
    headers = ['filename', 'usWidthClass was', 'usWidthClass now']

    for font in fonts:
        row = [font]
        ttfont = ttLib.TTFont(font)
        if not value:
            usWidthClass = getFromFilename(font)
        else:
            usWidthClass = value
        row.append(ttfont['OS/2'].usWidthClass)
        ttfont['OS/2'].usWidthClass = usWidthClass
        row.append(ttfont['OS/2'].usWidthClass)
        ttfont.save(font + '.fix')
        rows.append(row)

    if rows:
        print(tabulate.tabulate(rows, headers, tablefmt="pipe")) 
开发者ID:googlefonts,项目名称:gftools,代码行数:21,代码来源:gftools-list-widthclass.py

示例7: list_images

# 需要导入模块: import tabulate [as 别名]
# 或者: from tabulate import tabulate [as 别名]
def list_images(cli_ctx, short, installed):
    '''List all configured images.'''
    async def _impl():
        async with config_ctx(cli_ctx) as config_server:
            displayed_items = []
            try:
                items = await config_server.list_images()
                for item in items:
                    if installed and not item['installed']:
                        continue
                    if short:
                        img = ImageRef(f"{item['name']}:{item['tag']}",
                                       item['registry'])
                        displayed_items.append((img.canonical, item['digest']))
                    else:
                        pprint(item)
                if short:
                    print(tabulate(displayed_items, tablefmt='plain'))
            except Exception:
                log.exception('An error occurred.')
    with cli_ctx.logger:
        asyncio.run(_impl()) 
开发者ID:lablup,项目名称:backend.ai-manager,代码行数:24,代码来源:etcd.py

示例8: print_results_per_class

# 需要导入模块: import tabulate [as 别名]
# 或者: from tabulate import tabulate [as 别名]
def print_results_per_class(avg_cls_results, all_avg_results):

    metrics = list(all_avg_results.keys())

    # result printing
    avg_results_print = copy.deepcopy(avg_cls_results)
    avg_results_print['== Mean =='] = all_avg_results
    tab_rows = []
    for cls_, cls_metrics in avg_results_print.items():
        tab_row = [cls_]
        for metric in metrics:
            val = cls_metrics[metric]
            tab_row.append("%1.3f" % val)
        tab_rows.append(tab_row)
    headers = ['classes']
    headers.extend(copy.deepcopy(metrics))
    print(tabulate(tab_rows, headers=headers)) 
开发者ID:facebookresearch,项目名称:c3dpo_nrsfm,代码行数:19,代码来源:eval_zoo.py

示例9: _targets_heist

# 需要导入模块: import tabulate [as 别名]
# 或者: from tabulate import tabulate [as 别名]
def _targets_heist(self, ctx):
        """Shows a list of targets"""
        guild = ctx.guild
        theme = await self.thief.get_guild_theme(guild)
        targets = await self.thief.get_guild_targets(guild)
        t_vault = theme["Vault"]

        if len(targets.keys()) < 0:
            msg = ("There aren't any targets! To create a target use {}heist "
                   "createtarget .".format(ctx.prefix))
        else:
            target_names = [x for x in targets]
            crews = [int(subdict["Crew"]) for subdict in targets.values()]
            success = [str(subdict["Success"]) + "%" for subdict in targets.values()]
            vaults = [subdict["Vault"] for subdict in targets.values()]
            data = list(zip(target_names, crews, vaults, success))
            table_data = sorted(data, key=itemgetter(1), reverse=True)
            table = tabulate(table_data, headers=["Target", "Max Crew", t_vault, "Success Rate"])
            msg = "```C\n{}```".format(table)

        await ctx.send(msg) 
开发者ID:Malarne,项目名称:discord_cogs,代码行数:23,代码来源:heist.py

示例10: validate_env

# 需要导入模块: import tabulate [as 别名]
# 或者: from tabulate import tabulate [as 别名]
def validate_env(env, arch):
    env_map = EnvClient().get_all()
    envs = env_map.get(arch)
    if envs:
        if env not in envs:
            envlist = tabulate([
                [env_name]
                for env_name in sorted(envs.keys())
            ])
            floyd_logger.error("%s is not in the list of supported environments:\n%s", env, envlist)
            return False
    else:
        floyd_logger.error("invalid instance type")
        return False

    return True 
开发者ID:floydhub,项目名称:floyd-cli,代码行数:18,代码来源:run.py

示例11: info

# 需要导入模块: import tabulate [as 别名]
# 或者: from tabulate import tabulate [as 别名]
def info(job_name_or_id):
    """
    View detailed information of a job.
    """
    try:
        experiment = ExperimentClient().get(normalize_job_name(job_name_or_id))
    except FloydException:
        experiment = ExperimentClient().get(job_name_or_id)

    task_instance_id = get_module_task_instance_id(experiment.task_instances)
    task_instance = TaskInstanceClient().get(task_instance_id) if task_instance_id else None
    normalized_job_name = normalize_job_name(experiment.name)
    table = [["Job name", normalized_job_name],
             ["Created", experiment.created_pretty],
             ["Status", experiment.state], ["Duration(s)", experiment.duration_rounded],
             ["Instance", experiment.instance_type_trimmed],
             ["Description", experiment.description],
             ["Metrics", format_metrics(experiment.latest_metrics)]]
    if task_instance and task_instance.mode in ['jupyter', 'serving']:
        table.append(["Mode", task_instance.mode])
        table.append(["Url", experiment.service_url])
    if experiment.tensorboard_url:
        table.append(["TensorBoard", experiment.tensorboard_url])
    floyd_logger.info(tabulate(table)) 
开发者ID:floydhub,项目名称:floyd-cli,代码行数:26,代码来源:experiment.py

示例12: test_numpy_2d

# 需要导入模块: import tabulate [as 别名]
# 或者: from tabulate import tabulate [as 别名]
def test_numpy_2d():
    "Input: a 2D NumPy array with headers."
    try:
        import numpy

        na = (numpy.arange(1, 10, dtype=numpy.float32).reshape((3, 3)) ** 3) * 0.5
        expected = "\n".join(
            [
                "    a      b      c",
                "-----  -----  -----",
                "  0.5    4     13.5",
                " 32     62.5  108",
                "171.5  256    364.5",
            ]
        )
        result = tabulate(na, ["a", "b", "c"])
        assert_equal(expected, result)
    except ImportError:
        skip("test_numpy_2d is skipped") 
开发者ID:astanin,项目名称:python-tabulate,代码行数:21,代码来源:test_input.py

示例13: test_numpy_record_array

# 需要导入模块: import tabulate [as 别名]
# 或者: from tabulate import tabulate [as 别名]
def test_numpy_record_array():
    "Input: a 2D NumPy record array without header."
    try:
        import numpy

        na = numpy.asarray(
            [("Alice", 23, 169.5), ("Bob", 27, 175.0)],
            dtype={
                "names": ["name", "age", "height"],
                "formats": ["a32", "uint8", "float32"],
            },
        )
        expected = "\n".join(
            [
                "-----  --  -----",
                "Alice  23  169.5",
                "Bob    27  175",
                "-----  --  -----",
            ]
        )
        result = tabulate(na)
        assert_equal(expected, result)
    except ImportError:
        skip("test_numpy_2d_keys is skipped") 
开发者ID:astanin,项目名称:python-tabulate,代码行数:26,代码来源:test_input.py

示例14: test_numpy_record_array_keys

# 需要导入模块: import tabulate [as 别名]
# 或者: from tabulate import tabulate [as 别名]
def test_numpy_record_array_keys():
    "Input: a 2D NumPy record array with column names as headers."
    try:
        import numpy

        na = numpy.asarray(
            [("Alice", 23, 169.5), ("Bob", 27, 175.0)],
            dtype={
                "names": ["name", "age", "height"],
                "formats": ["a32", "uint8", "float32"],
            },
        )
        expected = "\n".join(
            [
                "name      age    height",
                "------  -----  --------",
                "Alice      23     169.5",
                "Bob        27     175",
            ]
        )
        result = tabulate(na, headers="keys")
        assert_equal(expected, result)
    except ImportError:
        skip("test_numpy_2d_keys is skipped") 
开发者ID:astanin,项目名称:python-tabulate,代码行数:26,代码来源:test_input.py

示例15: test_numpy_record_array_headers

# 需要导入模块: import tabulate [as 别名]
# 或者: from tabulate import tabulate [as 别名]
def test_numpy_record_array_headers():
    "Input: a 2D NumPy record array with user-supplied headers."
    try:
        import numpy

        na = numpy.asarray(
            [("Alice", 23, 169.5), ("Bob", 27, 175.0)],
            dtype={
                "names": ["name", "age", "height"],
                "formats": ["a32", "uint8", "float32"],
            },
        )
        expected = "\n".join(
            [
                "person      years     cm",
                "--------  -------  -----",
                "Alice          23  169.5",
                "Bob            27  175",
            ]
        )
        result = tabulate(na, headers=["person", "years", "cm"])
        assert_equal(expected, result)
    except ImportError:
        skip("test_numpy_2d_keys is skipped") 
开发者ID:astanin,项目名称:python-tabulate,代码行数:26,代码来源:test_input.py


注:本文中的tabulate.tabulate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。