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


Python AsciiTable.title方法代码示例

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


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

示例1: test_title

# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import title [as 别名]
def test_title():
    """Test that table title shows up correctly."""
    table_data = [
        ['Name', 'Color', 'Type'],
        ['Avocado', 'green', 'nut'],
        ['Tomato', 'red', 'fruit'],
        ['Lettuce', 'green', 'vegetable'],
    ]
    table = AsciiTable(table_data, 'Foods')

    expected = dedent("""\
        +Foods----+-------+-----------+
        | Name    | Color | Type      |
        +---------+-------+-----------+
        | Avocado | green | nut       |
        | Tomato  | red   | fruit     |
        | Lettuce | green | vegetable |
        +---------+-------+-----------+""")
    assert expected == table.table

    table.title = 'Foooooooooooooods'
    expected = dedent("""\
        +Foooooooooooooods+-----------+
        | Name    | Color | Type      |
        +---------+-------+-----------+
        | Avocado | green | nut       |
        | Tomato  | red   | fruit     |
        | Lettuce | green | vegetable |
        +---------+-------+-----------+""")
    assert expected == table.table

    table.title = 'Foooooooooooooodsssssssssssss'
    expected = dedent("""\
        +Foooooooooooooodsssssssssssss+
        | Name    | Color | Type      |
        +---------+-------+-----------+
        | Avocado | green | nut       |
        | Tomato  | red   | fruit     |
        | Lettuce | green | vegetable |
        +---------+-------+-----------+""")
    assert expected == table.table

    table.title = 'Foooooooooooooodssssssssssssss'
    expected = dedent("""\
        +---------+-------+-----------+
        | Name    | Color | Type      |
        +---------+-------+-----------+
        | Avocado | green | nut       |
        | Tomato  | red   | fruit     |
        | Lettuce | green | vegetable |
        +---------+-------+-----------+""")
    assert expected == table.table
开发者ID:aleivag,项目名称:terminaltables,代码行数:54,代码来源:test_table.py

示例2: output_ascii_table_list

# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import title [as 别名]
def output_ascii_table_list(table_title=None,
                            table_data=None,
                            table_header=None,
                            inner_heading_row_border=False,
                            inner_row_border=False):
    """
    @type table_title: unicode
    @type table_data: list
    @type inner_heading_row_border: bool
    @type inner_row_border: bool
    @type table_header: list
    """
    console_rows, _ = get_console_dimensions()
    console_rows = int(console_rows)
    full_display_length = len(table_data) + 7
    items_per_page = console_rows - 7
    num_pages = 0
    if full_display_length > console_rows:
        try:
            num_pages = int(math.ceil(float(len(table_data)) / float(items_per_page)))
        except ZeroDivisionError:
            exit('Console too small to display.')
    if num_pages:
        running_count = 0
        for page in range(1, num_pages + 1):
            page_table_output = list()
            page_table_output.insert(0, table_header)
            upper = (console_rows + running_count) - 7
            if upper > len(table_data):
                upper = len(table_data)
            for x in range(running_count, upper):
                page_table_output.append(table_data[x])
                running_count += 1
            table = AsciiTable(page_table_output)
            table.inner_heading_row_border = inner_heading_row_border
            table.inner_row_border = inner_row_border
            table.title = table_title
            if page != 1:
                print('')
            print(table.table)
            if page < num_pages:
                input("Press Enter to continue...")
                os.system('clear')
    else:
        table_data.insert(0, table_header)
        table = AsciiTable(table_data)
        table.inner_heading_row_border = inner_heading_row_border
        table.inner_row_border = inner_row_border
        table.title = table_title
        print(table.table)
开发者ID:jonhadfield,项目名称:acli,代码行数:52,代码来源:__init__.py

示例3: print_table

# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import title [as 别名]
 def print_table(self, data, title=None):
     print ""
     table = AsciiTable(data)
     if title:
         table.title = title
     print table.table
     print ""
开发者ID:0xe7,项目名称:CrackMapExec,代码行数:9,代码来源:cmedb.py

示例4: frameTable

# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import title [as 别名]
 def frameTable():
     frameTableP1 = [
     [],['Frame#', 'Process#', 'Page#'],
     [('\n'.join(map(str,range(16)))),('\n'.join(map(str,[j[1][0] for j in zipFrame]))),
     (('\n'.join(map(str,[l[1][1] for l in zipFrame]))))]
     ]
     table1 = AsciiTable(frameTableP1)
     table1.title='--------FRAME TABLE'
     print table1.table
开发者ID:dlombardi91,项目名称:LRUpagedVM,代码行数:11,代码来源:proj3.py

示例5: callback

# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import title [as 别名]
def callback(msg, has_printed):
    """Callback function called by libnl upon receiving messages from the kernel.

    Positional arguments:
    msg -- nl_msg class instance containing the data sent by the kernel.
    has_printed -- simple pseudo boolean (if list is empty) to keep track of when to print emtpy lines.

    Returns:
    An integer, value of NL_SKIP. It tells libnl to stop calling other callbacks for this message and proceed with
    processing the next kernel message.
    """
    table = AsciiTable([['Data Type', 'Data Value']])
    # First convert `msg` into something more manageable.
    gnlh = genlmsghdr(nlmsg_data(nlmsg_hdr(msg)))

    # Partially parse the raw binary data and place them in the `tb` dictionary.
    tb = dict((i, None) for i in range(nl80211.NL80211_ATTR_MAX + 1))  # Need to populate dict with all possible keys.
    nla_parse(tb, nl80211.NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), genlmsg_attrlen(gnlh, 0), None)

    # Now it's time to grab the juicy data!
    if tb[nl80211.NL80211_ATTR_IFNAME]:
        table.title = nla_get_string(tb[nl80211.NL80211_ATTR_IFNAME]).decode('ascii')
    else:
        table.title = 'Unnamed Interface'

    if tb[nl80211.NL80211_ATTR_WIPHY]:
        wiphy_num = nla_get_u32(tb[nl80211.NL80211_ATTR_WIPHY])
        wiphy = ('wiphy {0}' if OPTIONS['<interface>'] else 'phy#{0}').format(wiphy_num)
        table.table_data.append(['NL80211_ATTR_WIPHY', wiphy])

    if tb[nl80211.NL80211_ATTR_MAC]:
        mac_address = ':'.join(format(x, '02x') for x in nla_data(tb[nl80211.NL80211_ATTR_MAC])[:6])
        table.table_data.append(['NL80211_ATTR_MAC', mac_address])

    if tb[nl80211.NL80211_ATTR_IFINDEX]:
        table.table_data.append(['NL80211_ATTR_IFINDEX', str(nla_get_u32(tb[nl80211.NL80211_ATTR_IFINDEX]))])

    # Print all data.
    if has_printed:
        print()
    else:
        has_printed.append(True)
    print(table.table)
    return NL_SKIP
开发者ID:ewa,项目名称:libnl,代码行数:46,代码来源:example_show_wifi_interface.py

示例6: pTable5

# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import title [as 别名]
        def pTable5():
            ####process table p5
            pageTableP5 = [[],
            ['Page #', 'Frame#'],
            [('\n'.join(map(str,newP5))),

            ('\n'.join(map(str,([i for i,c in enumerate(zipFrame) if c[1][0]=='P5:'   ]))))]
            ]
            table5 = AsciiTable(pageTableP5)
            table5.title='---P5 Page Table'
            print table5.table
开发者ID:dlombardi91,项目名称:LRUpagedVM,代码行数:13,代码来源:proj3.py

示例7: pTable4

# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import title [as 别名]
        def pTable4():
            ####process table p4
            pageTableP4 = [[],
            ['Page #', 'Frame#'],
            [('\n'.join(map(str,newP4))),

            ('\n'.join(map(str,([i for i,c in enumerate(zipFrame) if c[1][0]=='P4:'   ]))))]
            ]
            table4 = AsciiTable(pageTableP4)
            table4.title='---4 Page Table'
            print table4.table
开发者ID:dlombardi91,项目名称:LRUpagedVM,代码行数:13,代码来源:proj3.py

示例8: pTable3

# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import title [as 别名]
        def pTable3():
            ####process table p3
            pageTableP3 = [[],
            ['Page #', 'Frame#'],
            [('\n'.join(map(str,newP3))),

            ('\n'.join(map(str,([i for i,c in enumerate(zipFrame) if c[1][0]=='P3:'   ]))))]
            ]
            table3 = AsciiTable(pageTableP3)
            table3.title='---P3 Page Table'
            print table3.table
开发者ID:dlombardi91,项目名称:LRUpagedVM,代码行数:13,代码来源:proj3.py

示例9: pTable2

# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import title [as 别名]
        def pTable2():
            ####process table p2
            pageTableP2 = [[],
            ['Page #', 'Frame#'],
            [('\n'.join(map(str,newP2))),

            ('\n'.join(map(str,([i for i,c in enumerate(zipFrame) if c[1][0]=='P2:'   ]))))]
            ]
            table2 = AsciiTable(pageTableP2)
            table2.title='---P2 Page Table'
            print table2.table
开发者ID:dlombardi91,项目名称:LRUpagedVM,代码行数:13,代码来源:proj3.py

示例10: pTable1

# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import title [as 别名]
        def pTable1():
            ####process table p1
            pageTableP1 = [[],
            ['Page #', 'Frame#'],
            [('\n'.join(map(str,newP1))),

            ('\n'.join(map(str,([i for i,c in enumerate(zipFrame) if c[1][0]=='P1:'   ]))))]
            ]
            table = AsciiTable(pageTableP1)
            table.title='---P1 Page Table'
            print table.table
开发者ID:dlombardi91,项目名称:LRUpagedVM,代码行数:13,代码来源:proj3.py

示例11: output_ascii_table

# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import title [as 别名]
def output_ascii_table(table_title=None,
                       table_data=None,
                       inner_heading_row_border=False,
                       inner_footing_row_border=False,
                       inner_row_border=False):
    """
    @type table_title: unicode
    @type table_data: list
    @type inner_heading_row_border: bool
    @type inner_footing_row_border: bool
    @type inner_row_border: bool
    """
    table = AsciiTable(table_data)
    table.inner_heading_row_border = inner_heading_row_border
    table.inner_row_border = inner_row_border
    table.inner_footing_row_border = inner_footing_row_border
    table.title = table_title
    print(table.table)
开发者ID:jonhadfield,项目名称:acli,代码行数:20,代码来源:__init__.py

示例12: info

# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import title [as 别名]
    def info(self, options):
        """
        Display service status information.

        Usage: info
        """

        from terminaltables import AsciiTable
        rows = []

        for key, value in self.project.info().iteritems():
            rows.append([key + ':', value])

        table = AsciiTable(rows)
        table.outer_border = False
        table.inner_column_border = False
        table.inner_heading_row_border = False
        table.title = 'Dork status information'
        print table.table
开发者ID:sepal,项目名称:compose,代码行数:21,代码来源:injections.py

示例13: calc_min_delay

# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import title [as 别名]
        damage, hit, base_delay = parts[2:5]

    # find weapon sizes
    if re.match('.*SIZE_.*SIZE_', line):
        # skip long gone items
        if 'old ' in title[0:4]:
            continue
        parts = [x.strip() for x in line.split(',')]
        double_hand, single_hand = parts[1:3]
        min_delay = calc_min_delay(base_delay)
        skill_required = calc_skill_required(base_delay, min_delay)
        th = parse_2h_size(double_hand, parse_1h_size(single_hand), parts[0])
        table_data.append([title, damage, hit, base_delay, min_delay, skill_required, th])

# table_data = sorted(table_data, key=lambda x: x[0])
table_data.insert(0, header)
table_data.append(header)

table = AsciiTable(table_data)
table.title = table_title
table.inner_footing_row_border = True
table.justify_columns[1] = 'right'
table.justify_columns[2] = 'right'
table.justify_columns[3] = 'right'
table.justify_columns[4] = 'right'
table.justify_columns[5] = 'right'

print(table.table)
print('\r')
print('Last generated on {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now()))
开发者ID:shmup,项目名称:dcss-scripts,代码行数:32,代码来源:dcss-weapons.py

示例14: zip

# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import title [as 别名]
            z =  zip(n,x)
            p.append(z)

            print (pageNum, "added to P1 page table")
        frm = map(str,x)


#terminaltable print#
    pageTableP1 = [[],
    ['Page #', 'Frame#'],
    [('\n'.join(map(str,x))),
    ('\n'.join(map(str,(i for i,x in enumerate(frm)))))]
    ]
    table = AsciiTable(pageTableP1)

    table.title='---P1 Page Table'
    print table.table



    frameTableP1 = [
    [],['Frame#', 'Process#', 'Page#'],
    [('\n'.join(map(str,frameTable))),('\n'.join(map(str,n))), (('\n'.join(map(str,x)))) ]
    ]
    table1 = AsciiTable(frameTableP1)
    table1.title='--------FRAME TABLE'
    print table1.table
#    pp.pprint(d['P2:'])
    validBitP2 = [1]*len(d['P2:'])
    resBitP2 = [0]*len(d['P2:'])
    zippedP2 = zip(d['P2:'], validBitP2, resBitP2)
开发者ID:dlombardi91,项目名称:LRUpagedVM,代码行数:33,代码来源:project3.py

示例15: test_attributes

# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import title [as 别名]
def test_attributes():
    """Test table attributes."""
    table_data = [
        ['Name', 'Color', 'Type'],
        ['Avocado', 'green', 'nut'],
        ['Tomato', 'red', 'fruit'],
        ['Lettuce', 'green', 'vegetable'],
        ['Watermelon', 'green']
    ]
    table = AsciiTable(table_data)

    table.justify_columns[0] = 'right'
    expected = dedent("""\
        +------------+-------+-----------+
        |       Name | Color | Type      |
        +------------+-------+-----------+
        |    Avocado | green | nut       |
        |     Tomato | red   | fruit     |
        |    Lettuce | green | vegetable |
        | Watermelon | green |           |
        +------------+-------+-----------+""")
    assert expected == table.table

    table.justify_columns[2] = 'center'
    expected = dedent("""\
        +------------+-------+-----------+
        |       Name | Color |    Type   |
        +------------+-------+-----------+
        |    Avocado | green |    nut    |
        |     Tomato | red   |   fruit   |
        |    Lettuce | green | vegetable |
        | Watermelon | green |           |
        +------------+-------+-----------+""")
    assert expected == table.table

    table.inner_heading_row_border = False
    expected = dedent("""\
        +------------+-------+-----------+
        |       Name | Color |    Type   |
        |    Avocado | green |    nut    |
        |     Tomato | red   |   fruit   |
        |    Lettuce | green | vegetable |
        | Watermelon | green |           |
        +------------+-------+-----------+""")
    assert expected == table.table

    table.title = 'Foods'
    table.inner_column_border = False
    expected = dedent("""\
        +Foods-------------------------+
        |       Name  Color     Type   |
        |    Avocado  green     nut    |
        |     Tomato  red      fruit   |
        |    Lettuce  green  vegetable |
        | Watermelon  green            |
        +------------------------------+""")
    assert expected == table.table

    table.outer_border = False
    expected = (
        '       Name  Color     Type   \n'
        '    Avocado  green     nut    \n'
        '     Tomato  red      fruit   \n'
        '    Lettuce  green  vegetable \n'
        ' Watermelon  green            '
    )
    assert expected == table.table

    table.outer_border = True
    table.inner_row_border = True
    expected = dedent("""\
        +Foods-------------------------+
        |       Name  Color     Type   |
        +------------------------------+
        |    Avocado  green     nut    |
        +------------------------------+
        |     Tomato  red      fruit   |
        +------------------------------+
        |    Lettuce  green  vegetable |
        +------------------------------+
        | Watermelon  green            |
        +------------------------------+""")
    assert expected == table.table

    table.title = False
    table.inner_column_border = True
    table.inner_heading_row_border = False  # Ignored due to inner_row_border.
    table.inner_row_border = True
    expected = dedent("""\
        +------------+-------+-----------+
        |       Name | Color |    Type   |
        +------------+-------+-----------+
        |    Avocado | green |    nut    |
        +------------+-------+-----------+
        |     Tomato | red   |   fruit   |
        +------------+-------+-----------+
        |    Lettuce | green | vegetable |
        +------------+-------+-----------+
        | Watermelon | green |           |
        +------------+-------+-----------+""")
#.........这里部分代码省略.........
开发者ID:aleivag,项目名称:terminaltables,代码行数:103,代码来源:test_table.py


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