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


Python AsciiTable.justify_columns方法代码示例

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


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

示例1: __report_summary_labels

# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import justify_columns [as 别名]
    def __report_summary_labels(self, cumulative):
        data = [("label", "status", "succ", "avg_rt", "error")]
        justify = {0: "left", 1: "center", 2: "right", 3: "right", 4: "left"}

        sorted_labels = sorted(cumulative.keys())
        for sample_label in sorted_labels:
            if sample_label != "":
                data.append(self.__get_sample_element(cumulative[sample_label], sample_label))
        table = SingleTable(data) if sys.stdout.isatty() else AsciiTable(data)
        table.justify_columns = justify
        self.log.info("Request label stats:\n%s", table.table)
开发者ID:andy7i,项目名称:taurus,代码行数:13,代码来源:reporting.py

示例2: test_multi_line

# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import justify_columns [as 别名]
def test_multi_line():
    """Test multi-lined cells."""
    table_data = [
        ['Show', 'Characters'],
        ['Rugrats', 'Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille, Angelica Pickles,\nDil Pickles'],
        ['South Park', 'Stan Marsh, Kyle Broflovski, Eric Cartman, Kenny McCormick']
    ]
    table = AsciiTable(table_data)

    # Test defaults.
    actual = table.table
    expected = (
        '+------------+-------------------------------------------------------------------------------------+\n'
        '| Show       | Characters                                                                          |\n'
        '+------------+-------------------------------------------------------------------------------------+\n'
        '| Rugrats    | Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille, Angelica Pickles, |\n'
        '|            | Dil Pickles                                                                         |\n'
        '| South Park | Stan Marsh, Kyle Broflovski, Eric Cartman, Kenny McCormick                          |\n'
        '+------------+-------------------------------------------------------------------------------------+'
    )
    assert actual == expected

    # Test inner row border.
    table.inner_row_border = True
    actual = table.table
    expected = (
        '+------------+-------------------------------------------------------------------------------------+\n'
        '| Show       | Characters                                                                          |\n'
        '+------------+-------------------------------------------------------------------------------------+\n'
        '| Rugrats    | Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille, Angelica Pickles, |\n'
        '|            | Dil Pickles                                                                         |\n'
        '+------------+-------------------------------------------------------------------------------------+\n'
        '| South Park | Stan Marsh, Kyle Broflovski, Eric Cartman, Kenny McCormick                          |\n'
        '+------------+-------------------------------------------------------------------------------------+'
    )
    assert actual == expected

    # Justify right.
    table.justify_columns = {1: 'right'}
    actual = table.table
    expected = (
        '+------------+-------------------------------------------------------------------------------------+\n'
        '| Show       |                                                                          Characters |\n'
        '+------------+-------------------------------------------------------------------------------------+\n'
        '| Rugrats    | Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille, Angelica Pickles, |\n'
        '|            |                                                                         Dil Pickles |\n'
        '+------------+-------------------------------------------------------------------------------------+\n'
        '| South Park |                          Stan Marsh, Kyle Broflovski, Eric Cartman, Kenny McCormick |\n'
        '+------------+-------------------------------------------------------------------------------------+'
    )
    assert actual == expected
开发者ID:Robpol86,项目名称:terminaltables,代码行数:53,代码来源:test_ascii_table.py

示例3: display_pull_stats

# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import justify_columns [as 别名]
def display_pull_stats(reviewers, reviewer_workload):
    table_data = [
        ['Assignee', '# assigned'],
    ]

    total = 0
    for reviewer in reviewers:
        workload = reviewer_workload[reviewer]
        table_data.append(
            [reviewer, six.text_type(workload)]
        )
        total += workload

    table_data.append(['TOTAL: ', six.text_type(total)])

    table = AsciiTable(table_data)
    table.inner_footing_row_border = True
    table.justify_columns = {1: 'center'}
    print(table.table)
开发者ID:agamdua,项目名称:mirage,代码行数:21,代码来源:assign.py

示例4: test_multi_line

# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import justify_columns [as 别名]
def test_multi_line():
    """Test multi-line tables."""
    table_data = [
        ['Show', 'Characters'],
        ['Rugrats', dedent('Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille, Angelica Pickles,\n'
                           'Susie Carmichael, Dil Pickles, Kimi Finster, Spike')],
        ['South Park', 'Stan Marsh, Kyle Broflovski, Eric Cartman, Kenny McCormick']
    ]
    table = AsciiTable(table_data)

    expected = dedent("""\
        +------------+-------------------------------------------------------------------------------------+
        | Show       | Characters                                                                          |
        +------------+-------------------------------------------------------------------------------------+
        | Rugrats    | Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille, Angelica Pickles, |
        |            | Susie Carmichael, Dil Pickles, Kimi Finster, Spike                                  |
        | South Park | Stan Marsh, Kyle Broflovski, Eric Cartman, Kenny McCormick                          |
        +------------+-------------------------------------------------------------------------------------+""")
    assert expected == table.table

    table.inner_row_border = True
    expected = dedent("""\
        +------------+-------------------------------------------------------------------------------------+
        | Show       | Characters                                                                          |
        +------------+-------------------------------------------------------------------------------------+
        | Rugrats    | Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille, Angelica Pickles, |
        |            | Susie Carmichael, Dil Pickles, Kimi Finster, Spike                                  |
        +------------+-------------------------------------------------------------------------------------+
        | South Park | Stan Marsh, Kyle Broflovski, Eric Cartman, Kenny McCormick                          |
        +------------+-------------------------------------------------------------------------------------+""")
    assert expected == table.table

    table.justify_columns = {1: 'right'}
    expected = dedent("""\
        +------------+-------------------------------------------------------------------------------------+
        | Show       |                                                                          Characters |
        +------------+-------------------------------------------------------------------------------------+
        | Rugrats    | Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille, Angelica Pickles, |
        |            |                                  Susie Carmichael, Dil Pickles, Kimi Finster, Spike |
        +------------+-------------------------------------------------------------------------------------+
        | South Park |                          Stan Marsh, Kyle Broflovski, Eric Cartman, Kenny McCormick |
        +------------+-------------------------------------------------------------------------------------+""")
    assert expected == table.table
开发者ID:aleivag,项目名称:terminaltables,代码行数:45,代码来源:test_table.py


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