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


Python prettytable.PLAIN_COLUMNS屬性代碼示例

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


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

示例1: _make_table

# 需要導入模塊: import prettytable [as 別名]
# 或者: from prettytable import PLAIN_COLUMNS [as 別名]
def _make_table(columns, header=False, align=None):
    """Make a table object for output."""
    if not align:
        align = {}

    table = prettytable.PrettyTable(columns)
    for col in columns:
        table.align[col] = align.get(col, 'l')

    table.set_style(prettytable.PLAIN_COLUMNS)
    # For some reason, headers must be disable after set_style.
    table.header = header

    table.left_padding_width = 0
    table.right_padding_width = 2
    return table 
開發者ID:Morgan-Stanley,項目名稱:treadmill,代碼行數:18,代碼來源:tablefmt.py

示例2: plain_column_table

# 需要導入模塊: import prettytable [as 別名]
# 或者: from prettytable import PLAIN_COLUMNS [as 別名]
def plain_column_table(header, align='l'):
    table = PrettyTable(header)
    table.set_style(PLAIN_COLUMNS)
    table.align = align
    return table 
開發者ID:anchore,項目名稱:anchore-cli,代碼行數:7,代碼來源:utils.py

示例3: printLevel2

# 需要導入模塊: import prettytable [as 別名]
# 或者: from prettytable import PLAIN_COLUMNS [as 別名]
def printLevel2(respjson, outformat, mainkey, listkey, subkey=None):
    if mainkey:
        parsed = json.loads(respjson)
    p=defaultprettytable(listkey)
    if(outformat.startswith("json")) :
        print(json.dumps(parsed, indent=4, sort_keys=True))
    else:
        if(outformat.startswith("text")):
            p.set_style(prettytable.PLAIN_COLUMNS)
        mainId = respjson
        if mainkey and len(mainkey) > 0:
            mainId = parsed[mainkey]

        for n in range(len(mainId)):
            item = mainId[n]
        #for item in mainId:
            if not (subkey is None):
                item = item[subkey]
            vals = list()
            for colkey in listkey:
                if colkey in item:
                    vals.append(item[colkey])
                else:
                    vals.append(" ")
            p.add_row(vals)
        print(p.get_string()) 
開發者ID:opentelekomcloud,項目名稱:python-otcclient,代碼行數:28,代碼來源:utils_output.py

示例4: printJsonTableTransverse

# 需要導入模塊: import prettytable [as 別名]
# 或者: from prettytable import PLAIN_COLUMNS [as 別名]
def printJsonTableTransverse(jsonval, outformat, mainkey):
    parsed = json.loads(jsonval)
    if(outformat.startswith("json")):
        print(json.dumps(parsed, indent=4, sort_keys=True))
    else:
        if(outformat.startswith("text")):
            x.set_style(prettytable.PLAIN_COLUMNS)
        if mainkey:
            id_generator(parsed[mainkey], "")
        else:
            id_generator(parsed, "")
        print(x.get_string()) 
開發者ID:opentelekomcloud,項目名稱:python-otcclient,代碼行數:14,代碼來源:utils_output.py

示例5: do_list

# 需要導入模塊: import prettytable [as 別名]
# 或者: from prettytable import PLAIN_COLUMNS [as 別名]
def do_list(self, args):
        """Lists registered agents"""
        t = PrettyTable(['ID', 'Hostname', 'User', 'IP Address', 'Version'])
        t.set_style(PLAIN_COLUMNS)
        conn = sqlite3.connect('slackor.db')
        cursor = conn.execute("SELECT id, hostname, user, ip, version from AGENTS")
        for row in cursor:
            ID = row[0]
            hostname = row[1]
            user = row[2]
            ipaddr = row[3]
            version = row[4]
            t.add_row([ID, hostname, user, ipaddr, version])
        print(color(t, "blue"))
        conn.close() 
開發者ID:Coalfire-Research,項目名稱:Slackor,代碼行數:17,代碼來源:server.py

示例6: show_cards

# 需要導入模塊: import prettytable [as 別名]
# 或者: from prettytable import PLAIN_COLUMNS [as 別名]
def show_cards(self, cards, tsv=False, sort='activity', table_fields=[]):
        '''Display an iterable of cards all at once.
        Uses a pretty-printed table by default, but can also print tab-separated values (TSV).
        Supports the following cli commands:
            show cards
            grep

        :param list(trello.Card)|iterable(trello.Card) cards: cards to show
        :param bool tsv: display these cards using a tab-separated value format
        :param str sort: the field name to sort by (must be a valid field name in this table)
        :param list table_fields: display only these fields
        '''
        # TODO construct the table dynamically instead of filtering down an already-constructed table
        # TODO implement a custom sorting functions so the table can be sorted by multiple columns
        table = prettytable.PrettyTable()
        table.field_names = self.fields.keys()
        table.align = 'l'
        if tsv:
            table.set_style(prettytable.PLAIN_COLUMNS)
        else:
            table.hrules = prettytable.FRAME
        with click.progressbar(list(cards), label='Fetching cards', width=0) as pg:
            for card in pg:
                table.add_row([x(card) for x in self.fields.values()])
        try:
            table[0]
        except IndexError:
            click.secho('No cards match!', fg='red')
            raise GTDException(1)
        if table_fields:
            print(table.get_string(fields=table_fields, sortby=sort))
        else:
            print(self.resize_and_get_table(table, self.fields.keys(), sort)) 
開發者ID:delucks,項目名稱:gtd.py,代碼行數:35,代碼來源:display.py

示例7: show_boards

# 需要導入模塊: import prettytable [as 別名]
# 或者: from prettytable import PLAIN_COLUMNS [as 別名]
def show_boards(ctx, use_json, tsv, by, show_all):
    '''Show all boards your account can access'''
    if show_all:
        boards = ctx.connection.trello.fetch_json('/members/me/boards/?filter=all')
    else:
        boards = ctx.connection.boards
    if use_json:
        print(json.dumps(boards, sort_keys=True, indent=2))
        return
    else:
        ctx.display.banner()
    # Set up a table to hold our boards
    board_columns = ['name', 'activity', 'members', 'permission', 'url']
    if by not in board_columns:
        click.secho(f'Field {by} is not a valid field: {",".join(board_columns)}', fg='red')
        raise GTDException(1)
    table = prettytable.PrettyTable()
    table.field_names = board_columns
    table.align = 'l'
    if tsv:
        table.set_style(prettytable.PLAIN_COLUMNS)
    else:
        table.hrules = prettytable.FRAME
    for b in boards:
        table.add_row(
            [
                b['name'],
                b['dateLastActivity'] or '',
                len(b['memberships']),
                b['prefs']['permissionLevel'],
                b['shortUrl'],
            ]
        )
    try:
        table[0]
    except IndexError:
        click.secho('You have no boards!', fg='red')
    print(table.get_string(sortby=by)) 
開發者ID:delucks,項目名稱:gtd.py,代碼行數:40,代碼來源:gtd.py

示例8: list_migrations

# 需要導入模塊: import prettytable [as 別名]
# 或者: from prettytable import PLAIN_COLUMNS [as 別名]
def list_migrations():
    db_conf = db_context()
    db_preflight(db_conf['params'], db_conf['retries'])

    with session_scope() as db:
        tasks = db_tasks.get_all(task_type=ArchiveMigrationTask, session=db, json_safe=True)

    fields = [
        'id',
        'state',
        'started_at',
        'ended_at',
        'migrate_from_driver',
        'migrate_to_driver',
        'archive_documents_migrated',
        'archive_documents_to_migrate',
        'last_updated'
    ]

    headers = [
        'id',
        'state',
        'start time',
        'end time',
        'from',
        'to',
        'migrated count',
        'total to migrate',
        'last updated'
    ]

    tbl = PrettyTable(field_names=headers)
    tbl.set_style(PLAIN_COLUMNS)
    for t in tasks:
        tbl.add_row([t[x] for x in fields])

    logger.info((tbl.get_string(sortby='id'))) 
開發者ID:anchore,項目名稱:anchore-engine,代碼行數:39,代碼來源:objectstorage.py


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