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


Python terminaltables.SingleTable方法代码示例

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


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

示例1: printserverinfo

# 需要导入模块: import terminaltables [as 别名]
# 或者: from terminaltables import SingleTable [as 别名]
def printserverinfo(data):
    """show vulnerable websites in table"""

    # [
    #   ["website", "server", "lang"],
    #   [sql.com", "apache", "php/5.5xxxx"]
    # ]

    # check if table column and data columns are the same
    if not all(isinstance(item, list) for item in data):
        stderr("program err, data must be two dimentional array")
        return

    title = " DOMAINS "
    table_data = [["website", "server", "lang"]] + data

    table = SingleTable(table_data, title)
    print(table.table) 
开发者ID:the-robot,项目名称:sqliv,代码行数:20,代码来源:std.py

示例2: normalprint

# 需要导入模块: import terminaltables [as 别名]
# 或者: from terminaltables import SingleTable [as 别名]
def normalprint(data):
    """show vulnerable websites in table"""

    # [
    #   ["index", "url"],
    #   ["1", "sql.com"]
    # ]

    title = " VULNERABLE URLS "
    table_data = [["index", "url", "db"]]
    # add into table_data by one by one
    for index, url in enumerate(data):
        table_data.append([index+1, url[0], url[1]])

    table = SingleTable(table_data, title)
    print(table.table) 
开发者ID:the-robot,项目名称:sqliv,代码行数:18,代码来源:std.py

示例3: fullprint

# 需要导入模块: import terminaltables [as 别名]
# 或者: from terminaltables import SingleTable [as 别名]
def fullprint(data):
    """show vulnerable websites in table with server info"""

    # [
    #   ["index", "url", "db", server", "lang"],
    #   ["1", "sql.com", "mysql", apache", "php/5.5xxx"]
    # ]

    title = " VULNERABLE URLS "
    table_data = [["index", "url", "db", "server", "lang"]]
    # add into table_data by one by one
    for index, each in enumerate(data):
        table_data.append([index+1, each[0], each[1], each[2][0:30], each[3][0:30]])

    table = SingleTable(table_data, title)
    print(table.table) 
开发者ID:the-robot,项目名称:sqliv,代码行数:18,代码来源:std.py

示例4: as_table

# 需要导入模块: import terminaltables [as 别名]
# 或者: from terminaltables import SingleTable [as 别名]
def as_table(tlv, title=None, redact=False):
    res = [["Tag", "Name", "Value"]]
    if type(tlv) is not TLV:
        return ""
    for tag, value in tlv.items():
        res.append(
            [
                format_bytes(tag.id),
                tag.name or "",
                "\n".join(textwrap.wrap(render_element(tag, value, redact=redact), 80)),
            ]
        )
    table = SingleTable(res)
    if title is not None:
        table.title = title
    return table.table 
开发者ID:russss,项目名称:python-emv,代码行数:18,代码来源:client.py

示例5: listapps

# 需要导入模块: import terminaltables [as 别名]
# 或者: from terminaltables import SingleTable [as 别名]
def listapps(ctx):
    card = get_reader(ctx.obj["reader"])
    apps = card.list_applications()
    res = [["Index", "Label", "ADF"]]
    i = 0
    for app in apps:
        res.append(
            [
                i,
                render_element(Tag.APP_LABEL, app[Tag.APP_LABEL]),
                render_element(Tag.ADF_NAME, app[Tag.ADF_NAME]),
            ]
        )
        i += 1

    table = SingleTable(res)
    table.title = "Applications"
    click.echo(table.table) 
开发者ID:russss,项目名称:python-emv,代码行数:20,代码来源:client.py

示例6: appdata

# 需要导入模块: import terminaltables [as 别名]
# 或者: from terminaltables import SingleTable [as 别名]
def appdata(ctx, app_index):
    redact = ctx.obj["redact"]
    card = get_reader(ctx.obj["reader"])
    apps = card.list_applications()
    app = apps[app_index]
    card.select_application(app[Tag.ADF_NAME])
    click.secho(
        "Selected application %s (%s)"
        % (
            render_element(Tag.APP_LABEL, app[Tag.APP_LABEL]),
            render_element(Tag.ADF_NAME, app[Tag.ADF_NAME]),
        ),
        bold=True,
    )
    opts = card.get_processing_options()

    res = [["Key", "Value"]]
    for k, v in opts.items():
        res.append((k, v))
    table = SingleTable(res)
    table.title = "Processing Options"
    click.echo(table.table)

    app_data = card.get_application_data(opts["AFL"])
    click.echo(as_table(app_data, title="Application Data", redact=redact)) 
开发者ID:russss,项目名称:python-emv,代码行数:27,代码来源:client.py

示例7: main

# 需要导入模块: import terminaltables [as 别名]
# 或者: from terminaltables import SingleTable [as 别名]
def main():
    """Main function."""
    title = 'Jetta SportWagen'

    # AsciiTable.
    table_instance = AsciiTable(TABLE_DATA, title)
    table_instance.justify_columns[2] = 'right'
    print(table_instance.table)
    print()

    # SingleTable.
    table_instance = SingleTable(TABLE_DATA, title)
    table_instance.justify_columns[2] = 'right'
    print(table_instance.table)
    print()

    # DoubleTable.
    table_instance = DoubleTable(TABLE_DATA, title)
    table_instance.justify_columns[2] = 'right'
    print(table_instance.table)
    print() 
开发者ID:Robpol86,项目名称:terminaltables,代码行数:23,代码来源:example1.py

示例8: table_abcd

# 需要导入模块: import terminaltables [as 别名]
# 或者: from terminaltables import SingleTable [as 别名]
def table_abcd():
    """Return table string to be printed. Two tables on one line."""
    table_instance = SingleTable([['A', 'B'], ['C', 'D']])

    # Get first table lines.
    table_instance.outer_border = False
    table_inner_borders = table_instance.table.splitlines()

    # Get second table lines.
    table_instance.outer_border = True
    table_instance.inner_heading_row_border = False
    table_instance.inner_column_border = False
    table_outer_borders = table_instance.table.splitlines()

    # Combine.
    smallest, largest = sorted([table_inner_borders, table_outer_borders], key=len)
    smallest += [''] * (len(largest) - len(smallest))  # Make both same size.
    combined = list()
    for i, row in enumerate(largest):
        combined.append(row.ljust(10) + '          ' + smallest[i])
    return '\n'.join(combined) 
开发者ID:Robpol86,项目名称:terminaltables,代码行数:23,代码来源:example2.py

示例9: main

# 需要导入模块: import terminaltables [as 别名]
# 或者: from terminaltables import SingleTable [as 别名]
def main():
    """Main function."""
    Windows.enable(auto_colors=True, reset_atexit=True)  # Does nothing if not on Windows.

    # Server timings.
    print(table_server_timings())
    print()

    # Server status.
    print(table_server_status())
    print()

    # Two A B C D tables.
    print(table_abcd())
    print()

    # Instructions.
    table_instance = SingleTable([['Obey Obey Obey Obey']], 'Instructions')
    print(table_instance.table)
    print() 
开发者ID:Robpol86,项目名称:terminaltables,代码行数:22,代码来源:example2.py

示例10: __init__

# 需要导入模块: import terminaltables [as 别名]
# 或者: from terminaltables import SingleTable [as 别名]
def __init__(self, data, title=None, wrap_cols=None, bool_cols=None, dim_rows=None):
        """Constructor.
        Args:
            data: Required. List[List] of data to format, with the heading as 0-th member.
            title: String to use as the table's title.
            wrap_cols: List[str] of column names to wrap to max width.
            bool_cols: List[str] of columns containing booleans to stringify.
            dim_rows: List[int] of row indices to dim.
        """
        self._data = data
        self._header = data[0]
        self._title = title
        self._table = SingleTable(self._data, self._title)

        if wrap_cols:
            self._table_wrapper(self._table, wrap_cols)
        if bool_cols:
            for name in bool_cols:
                self.stringify_boolean_col(col_name=name)
        if dim_rows:
            self._dim_row_list(dim_rows) 
开发者ID:SFDO-Tooling,项目名称:CumulusCI,代码行数:23,代码来源:ui.py

示例11: do_status

# 需要导入模块: import terminaltables [as 别名]
# 或者: from terminaltables import SingleTable [as 别名]
def do_status(self, line):
        """
    Display process pool status.
        """
        self.clean_tasks()
        # this prevents from re-displaying the same status table once ENTER is pressed
        #  (marker 'restart' is handled in emptyline() hereafter
        if line == 'restart' and self.__last_tasklist is not None and \
                        hash(repr(self.tasklist)) == self.__last_tasklist:
            return
        self.__last_tasklist = hash(repr(copy(self.tasklist)))
        if len(self.tasklist) == 0:
            data = [['No task currently running']]
        else:
            data = [['Task', 'Status', 'Result']]
            for task, info in sorted(self.tasklist.items(), key=lambda x: str(x[0])):
                data.append([str(task).ljust(15), info['status'].ljust(10), str(info['result']).ljust(40)])
        table = SingleTable(data, 'Status of opened tasks')
        table.justify_columns = {0: 'center', 1: 'center', 2: 'center'}
        print(table.table) 
开发者ID:dhondta,项目名称:rpl-attacks,代码行数:22,代码来源:console.py

示例12: list

# 需要导入模块: import terminaltables [as 别名]
# 或者: from terminaltables import SingleTable [as 别名]
def list(item_type, **kwargs):
    """
    List all available items of a specified type.

    :param item_type: experiment/campaign/wsn-generation-algorithm
    :param kwargs: simulation keyword arguments (see the documentation for more information)
    """
    data, title = [['Name']], None
    if item_type == 'experiments':
        title = 'Available experiments'
        data.extend([['- {}'.format(x).ljust(25)] for x in list_experiments()])
    elif item_type == 'campaigns':
        title = 'Available campaigns'
        data.extend([['- {}'.format(x).ljust(25)] for x in list_campaigns()])
    elif item_type == 'wsn-generation-algorithms':
        title = 'Available WSN generation algorithms'
        data.extend([['- {}'.format(x).ljust(25)] for x in list_wsn_gen_algorithms()])
    if title is not None:
        table = SingleTable(data, title)
        print(table.table)


# ***************************************** SETUP COMMANDS **************************************** 
开发者ID:dhondta,项目名称:rpl-attacks,代码行数:25,代码来源:commands.py

示例13: display

# 需要导入模块: import terminaltables [as 别名]
# 或者: from terminaltables import SingleTable [as 别名]
def display(id):
    ''' Display build information by build id. '''
    history = load_history()
    build = get_build_info(history, id or history['current'])
    is_current = build['id'] == history['current']
    timestamp = local_timestamp(build['timestamp'])

    table = SingleTable([
        [green('Build ' + build['id'])],
        ['ID: ' + green(build['id'])],
        ['Commit: ' + green(build['commit'])],
        ['Branch: ' + green(build['branch'])],
        ['Stage: ' + green(build['stage'])],
        ['Created By: ' + green(build['createdBy'])],
        ['Path: ' + green(build['path'])],
        ['Current Build: ' + green('Yes' if is_current else 'No')],
        ['Timestamp: ' + green(timestamp)]
    ])
    print(table.table) 
开发者ID:kabirbaidhya,项目名称:boss,代码行数:21,代码来源:buildman.py

示例14: display_list

# 需要导入模块: import terminaltables [as 别名]
# 或者: from terminaltables import SingleTable [as 别名]
def display_list(history):
    ''' Display build history. '''
    if not history['builds']:
        remote_info('No builds have been deployed yet.')
        return

    remote_info('Showing recent builds')

    # Map build data into tabular format
    data = map(row_mapper_wrt(history['current']), history['builds'])

    # Prepend heading rows
    data.insert(0, [
        ' ', 'ID', 'Commit',
        'Branch', 'Created By', 'Timestamp'
    ])

    table = SingleTable(data)
    print('')
    print(table.table) 
开发者ID:kabirbaidhya,项目名称:boss,代码行数:22,代码来源:buildman.py

示例15: _table_output

# 需要导入模块: import terminaltables [as 别名]
# 或者: from terminaltables import SingleTable [as 别名]
def _table_output(self, header, data, columns, title, to):
        """
        Pretty-prints data in a table
        """
        content = []

        if isinstance(columns[0], str):
            content=data
        else:
            for model in data:
                content.append([attr.render_value(model) for attr in columns])

        if self.headers:
            content = [header]+content

        tab = SingleTable(content)

        if title is not None:
            tab.title=title

        if not self.headers:
            tab.inner_heading_row_border = False

        print(tab.table, file=to) 
开发者ID:linode,项目名称:linode-cli,代码行数:26,代码来源:output.py


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