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


Python Table.get_table方法代碼示例

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


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

示例1: log_planets

# 需要導入模塊: from common.print_utils import Table [as 別名]
# 或者: from common.print_utils.Table import get_table [as 別名]
def log_planets():
    universe = fo.get_universe()

    planets_table = Table(
        [Text('id'), Text('name'), Text('system'), Text('type'),
         Sequence('specials'), Text('species'), Sequence('buildings')],
        table_name='Planets summary')
    # group planets by system
    for sid in fo.get_systems():
        for pid in fo.sys_get_planets(sid):
            planet = universe.getPlanet(pid)

            planet_type = fo.planet_get_type(pid).name
            planet_size = fo.planet_get_size(pid).name
            if planet_type != planet_size:
                planet_type = '%s %s' % (planet_type, planet_size)

            buildings = [universe.getBuilding(x).name for x in planet.buildingIDs]
            planets_table.add_row([
                pid, planet.name, planet.systemID, planet_type, list(planet.specials), planet.speciesName, buildings
            ])

    # Printing too much info at once will lead to truncation of text
    for line in planets_table.get_table().split('\n'):
        print line
開發者ID:Vezzra,項目名稱:freeorion,代碼行數:27,代碼來源:universe_statistics.py

示例2: test_empty_table

# 需要導入模塊: from common.print_utils import Table [as 別名]
# 或者: from common.print_utils.Table import get_table [as 別名]
def test_empty_table():
    empty = Table(
        [
            Text("name", description="Name for first column"),
            Float("value", description="VValue"),
            Sequence("zzz"),
            Sequence("zzzzzzzzzzzzzzzzzz"),
        ],
        table_name="Wooho",
    )
    assert empty.get_table() == EXPECTED_EMPTY_TABLE
開發者ID:Ouaz,項目名稱:freeorion,代碼行數:13,代碼來源:test_print_utils.py

示例3: log_systems

# 需要導入模塊: from common.print_utils import Table [as 別名]
# 或者: from common.print_utils.Table import get_table [as 別名]
def log_systems():
    universe = fo.get_universe()

    systems_table = Table(
        [Text('id'), Text('name'), Sequence('planets'), Sequence('connections'), Text('star')],
        table_name='System summary')
    for sid in fo.get_systems():
        system = universe.getSystem(sid)
        systems_table.add_row([
            sid, system.name, fo.sys_get_planets(sid), fo.sys_get_starlanes(sid), system.starType.name
        ])

    # Printing too much info at once will lead to truncation of text
    for line in systems_table.get_table().split('\n'):
        print line
開發者ID:Vezzra,項目名稱:freeorion,代碼行數:17,代碼來源:universe_statistics.py

示例4: test_simple_table

# 需要導入模塊: from common.print_utils import Table [as 別名]
# 或者: from common.print_utils.Table import get_table [as 別名]
def test_simple_table():
    t = Table(
        [
            Text("name", description="Name for first column"),
            Float("value", description="VValue"),
            Sequence("zzz"),
            Sequence("zzzzzzzzzzzzzzzzzz"),
        ],
        table_name="Wooho",
    )
    t.add_row(["hello", 144444, "abcffff", "a"])
    t.add_row([u"Plato aa\u03b2 III", 21, "de", "a"])
    t.add_row([u"Plato \u03b2 III", 21, "de", "a"])
    t.add_row(["Plato B III", 21, "d", "a"])
    t.add_row(["Plato Bddddd III", 21, "d", "a"])
    t.add_row(["Plato III", 21, "d", "a"])
    assert t.get_table() == EXPECTED_SIMPLE_TABLE
開發者ID:Ouaz,項目名稱:freeorion,代碼行數:19,代碼來源:test_print_utils.py


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