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


Python AsciiTable.outer_border方法代码示例

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


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

示例1: run

# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import outer_border [as 别名]
    def run(self):
        self.print_banner()
        self.print_help()

        while True:
            command = self.input()

            if command == 'addcert':
                count = self.manager.command_addcert()
                print "Successfully added %s certificates" % count

            elif command == 'settings':
                print SETTINGS

            elif command == 'help':
                self.print_banner()
                self.print_help()

            elif command == 'report':
                rows, week_start, week_end, total = self.manager.command_report()
                table = AsciiTable(rows, 'Certificates obtained %s-%s' % (week_start, week_end))
                table.outer_border = False
                print table.table
                print "\nTotal certificates obtained: %s" % total

            elif command == 'delete':
                self.manager.command_delete()

            elif command == 'exit':
                return 0
            else:
                pass
开发者ID:mbs-dev,项目名称:certman,代码行数:34,代码来源:__init__.py

示例2: test_attributes

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

    assert 31 == max(len(r) for r in table.table.splitlines())
    assert 31 == table.table_width

    table.outer_border = False
    assert 29 == max(len(r) for r in table.table.splitlines())
    assert 29 == table.table_width

    table.inner_column_border = False
    assert 27 == max(len(r) for r in table.table.splitlines())
    assert 27 == table.table_width

    table.padding_left = 0
    assert 24 == max(len(r) for r in table.table.splitlines())
    assert 24 == table.table_width

    table.padding_right = 0
    assert 21 == max(len(r) for r in table.table.splitlines())
    assert 21 == table.table_width
开发者ID:aleivag,项目名称:terminaltables,代码行数:30,代码来源:test_table_width_ok.py

示例3: output

# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import outer_border [as 别名]
def output(buf, dowrap=False):
    bbuf = [["Bot", "Pack#", "Size", "File"]] + buf
    t = AsciiTable(bbuf)
    t.inner_column_border = False
    t.outer_border = False
    if dowrap and sys.stdout.isatty():
        mw = t.column_max_width(3)
        for e in bbuf:
            if len(e[3])>mw:
                e[3] = "\n".join(wrap(e[3], mw))
    print(t.table)
    sys.stdout.flush()
开发者ID:2ion,项目名称:nibl,代码行数:14,代码来源:nibl.py

示例4: info

# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import outer_border [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

示例5: run_model

# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import outer_border [as 别名]

#.........这里部分代码省略.........
                    pmlinfo = ''
                    for key, value in G.pmlthickness.items():
                        pmlinfo += '{}: {}, '.format(key, value)
                    pmlinfo = pmlinfo[:-2]
                print('PML boundaries: {} cells'.format(pmlinfo))
            pbar = tqdm(total=sum(1 for value in G.pmlthickness.values() if value > 0), desc='Building PML boundaries', ncols=get_terminal_width() - 1, file=sys.stdout, disable=G.tqdmdisable)
            build_pmls(G, pbar)
            pbar.close()

        # Build the model, i.e. set the material properties (ID) for every edge of every Yee cell
        print()
        pbar = tqdm(total=2, desc='Building main grid', ncols=get_terminal_width() - 1, file=sys.stdout, disable=G.tqdmdisable)
        build_electric_components(G.solid, G.rigidE, G.ID, G)
        pbar.update()
        build_magnetic_components(G.solid, G.rigidH, G.ID, G)
        pbar.update()
        pbar.close()

        # Process any voltage sources (that have resistance) to create a new material at the source location
        for voltagesource in G.voltagesources:
            voltagesource.create_material(G)

        # Initialise arrays of update coefficients to pass to update functions
        G.initialise_std_update_coeff_arrays()

        # Initialise arrays of update coefficients and temporary values if there are any dispersive materials
        if Material.maxpoles != 0:
            G.initialise_dispersive_arrays()

        # Process complete list of materials - calculate update coefficients, store in arrays, and build text list of materials/properties
        materialsdata = process_materials(G)
        if G.messages:
            materialstable = AsciiTable(materialsdata)
            materialstable.outer_border = False
            materialstable.justify_columns[0] = 'right'
            print(materialstable.table)

        # Check to see if numerical dispersion might be a problem
        results = dispersion_analysis(G)
        if results['deltavp'] and np.abs(results['deltavp']) > G.maxnumericaldisp:
            print(Fore.RED + "\nWARNING: Potentially significant numerical dispersion. Largest physical phase-velocity error is {:.2f}% in material '{}' with wavelength sampled by {} cells (maximum significant frequency {:g}Hz)".format(results['deltavp'], results['material'].ID, round_value(results['N']), results['maxfreq']) + Style.RESET_ALL)
        elif results['deltavp']:
            print("\nNumerical dispersion analysis: largest physical phase-velocity error is {:.2f}% in material '{}' with wavelength sampled by {} cells (maximum significant frequency {:g}Hz)".format(results['deltavp'], results['material'].ID, round_value(results['N']), results['maxfreq']))

    # If geometry information to be reused between model runs
    else:
        inputfilestr = '\n--- Model {} of {}, input file (not re-processed, i.e. geometry fixed): {}'.format(modelrun, numbermodelruns, inputfile)
        print(Fore.GREEN + '{} {}\n'.format(inputfilestr, '-' * (get_terminal_width() - 1 - len(inputfilestr))) + Style.RESET_ALL)

        # Clear arrays for field components
        G.initialise_field_arrays()

        # Clear arrays for fields in PML
        for pml in G.pmls:
            pml.initialise_field_arrays()

    # Adjust position of simple sources and receivers if required
    if G.srcsteps[0] > 0 or G.srcsteps[1] > 0 or G.srcsteps[2] > 0:
        for source in itertools.chain(G.hertziandipoles, G.magneticdipoles):
            if modelrun == 1:
                if source.xcoord + G.srcsteps[0] * (numbermodelruns - 1) > G.nx or source.ycoord + G.srcsteps[1] * (numbermodelruns - 1) > G.ny or source.zcoord + G.srcsteps[2] * (numbermodelruns - 1) > G.nz:
                    raise GeneralError('Source(s) will be stepped to a position outside the domain.')
            source.xcoord = source.xcoordorigin + (modelrun - 1) * G.srcsteps[0]
            source.ycoord = source.ycoordorigin + (modelrun - 1) * G.srcsteps[1]
            source.zcoord = source.zcoordorigin + (modelrun - 1) * G.srcsteps[2]
    if G.rxsteps[0] > 0 or G.rxsteps[1] > 0 or G.rxsteps[2] > 0:
开发者ID:gprMax,项目名称:gprMax,代码行数:70,代码来源:gprMax.py

示例6: execute_status

# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import outer_border [as 别名]
def execute_status(args):
    status = get_status()
    # First rows, showing daemon status
    if status['status'] == 'running':
        status['status'] = Color('{autogreen}' + '{}'.format(status['status']) + '{/autogreen}')
    elif status['status'] == 'paused':
        status['status'] = Color('{autoyellow}' + '{}'.format(status['status']) + '{/autoyellow}')

    if status['process'] == 'running' or status['process'] == 'paused':
        status['process'] = Color('{autogreen}' + '{}'.format(status['process']) + '{/autogreen}')

    print('Daemon: {}\nProcess status: {} \n'.format(status['status'], status['process']))

    # Handle queue data
    data = status['data']
    if isinstance(data, str):
        print(data)
    elif isinstance(data, dict):
        # Format incomming data to be compatible with Terminaltables
        formatted_data = []
        formatted_data.append(['Index', 'Status', 'Code',
                               'Command', 'Path', 'Start', 'End'])
        for key, entry in sorted(data.items(), key=operator.itemgetter(0)):
            formatted_data.append(
                [
                    '#{}'.format(key),
                    entry['status'],
                    '{}'.format(entry['returncode']),
                    entry['command'],
                    entry['path'],
                    entry['start'],
                    entry['end']
                ]
            )

        # Create AsciiTable instance and define style
        table = AsciiTable(formatted_data)
        table.outer_border = False
        table.inner_column_border = False

        terminal_width = terminal_size()
        customWidth = table.column_widths
        # If the text is wider than the actual terminal size, we
        # compute a new size for the Command and Path column.
        if (reduce(lambda a, b: a+b, table.column_widths) + 10) > terminal_width[0]:
            # We have to subtract 14 because of table paddings
            left_space = math.floor((terminal_width[0] - customWidth[0] - customWidth[1] - customWidth[2] - customWidth[5] - customWidth[6] - 14)/2)

            if customWidth[3] < left_space:
                customWidth[4] = 2*left_space - customWidth[3]
            elif customWidth[4] < left_space:
                customWidth[3] = 2*left_space - customWidth[4]
            else:
                customWidth[3] = left_space
                customWidth[4] = left_space

        # Format long strings to match the console width
        for i, entry in enumerate(table.table_data):
            for j, string in enumerate(entry):
                max_width = customWidth[j]
                wrapped_string = '\n'.join(wrap(string, max_width))
                if j == 1:
                    if wrapped_string == 'done' or wrapped_string == 'running' or wrapped_string == 'paused':
                        wrapped_string = Color('{autogreen}' + '{}'.format(wrapped_string) + '{/autogreen}')
                    elif wrapped_string == 'queued':
                        wrapped_string = Color('{autoyellow}' + '{}'.format(wrapped_string) + '{/autoyellow}')
                    elif wrapped_string in ['errored', 'stopping', 'killing']:
                        wrapped_string = Color('{autored}' + '{}'.format(wrapped_string) + '{/autored}')
                elif j == 2:
                    if wrapped_string == '0' and wrapped_string != 'Code':
                        wrapped_string = Color('{autogreen}' + '{}'.format(wrapped_string) + '{/autogreen}')
                    elif wrapped_string != '0' and wrapped_string != 'Code':
                        wrapped_string = Color('{autored}' + '{}'.format(wrapped_string) + '{/autored}')

                table.table_data[i][j] = wrapped_string

        print(table.table)
    print('')
开发者ID:Nukesor,项目名称:pueue,代码行数:80,代码来源:displaying.py

示例7: AsciiTable

# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import outer_border [as 别名]
Just prints sample text and exits.
"""

from __future__ import print_function

from terminaltables import AsciiTable, DoubleTable


table_data = [
    ['Platform', 'Years', 'Notes'],
    ['Mk5', '2007-2009', '\033[37;41mUnavailable\033[0m'],
    ['MKVI', '2009-2013', 'Might actually be Mk5.'],
]
table = AsciiTable(table_data, 'wangbin')
print()
print(table.table)

table = DoubleTable(table_data, 'Jetta SportWagen')
table.inner_row_border = True
table.justify_columns[2] = 'right'
print()
print(table.table)

table.outer_border = False
table.justify_columns[1] = 'center'
print()
print(table.table)

print()
开发者ID:BillWang139967,项目名称:linux_terminal,代码行数:31,代码来源:example1.py

示例8: test_attributes

# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import outer_border [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.outer_border方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。