本文整理汇总了Python中terminaltables.AsciiTable.inner_row_border方法的典型用法代码示例。如果您正苦于以下问题:Python AsciiTable.inner_row_border方法的具体用法?Python AsciiTable.inner_row_border怎么用?Python AsciiTable.inner_row_border使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类terminaltables.AsciiTable
的用法示例。
在下文中一共展示了AsciiTable.inner_row_border方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: list
# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import inner_row_border [as 别名]
def list(self, name: str, running: bool, available: bool):
"""
Get running/available listeners
Usage: list [<name>] [--running] [--available] [-h]
Arguments:
name filter by listener name
Options:
-h, --help Show dis
-r, --running List running listeners
-a, --available List available listeners
"""
table_data = [
["Name", "Description"]
]
for l in self.loaded:
table_data.append([l.name, l.description])
table = AsciiTable(table_data, title="Available")
table.inner_row_border = True
print(table.table)
table_data = [
["Type", "Name", "URL"]
]
for l in self.listeners:
table_data.append([l.name, l["Name"], f"https://{l['BindIP']}:{l['Port']}"])
table = AsciiTable(table_data, title="Running")
table.inner_row_border = True
print(table.table)
示例2: output_ascii_table_list
# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import inner_row_border [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)
示例3: view_services
# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import inner_row_border [as 别名]
def view_services(filterquery=None):
"""Prints out list of services and its relevant information"""
table = []
table.append(["Service Name", "Stacks", "Containers", "Parent S", "Child S", "Endpoints" ])
if filterquery:
services = filterquery.all()
#services = session.query(filterquery).all()
else:
services = session.query(Service).all()
if not services:
print "No services met the search"
return
for service in services:
state = service.get_state()
parents = [p['parent'] for p in state['parent']]
children = [c['child'] for c in state['childs']]
cs = []
for stack in state['stacks']:
for i, container in enumerate(stack['container']):
endpoint = service.tree_on_stack_pointer(i)
if endpoint:
cs.append("%s:%s:%s" % (container['name'], container['version'], endpoint.name))
else:
cs.append("%s:%s" % (container['name'], container['version']))
#cs.extend(["%s:%s" % (c['name'],c['version']) for c in stack['container']])
table.append([str(state['name']),
"\n".join([ s['name'] for s in state['stacks'] if s]),
str("\n".join(cs)),
"\n".join(parents),
"\n".join(children),
"\n".join(state['endpoints'])])
t = AsciiTable(table)
t.inner_row_border = True
print t.table
示例4: write_out_results
# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import inner_row_border [as 别名]
def write_out_results(self):
stats = self._calc_stats()
rps = stats.rps
results_table_data = [
['Item', 'Value', 'Info'],
['Successful calls', '%r'%stats.count, '测试成功的连接数'],
['Total time', '%.4f'%stats.total_time, '总耗时'],
['Average Time', '%.4f'%stats.avg, '每个连接的平均耗时'],
['Fatest Time', '%.4f'%stats.min, '最小耗时'],
['Slowest Time', '%.4f'%stats.max, '最大耗时'],
['Amplitude', '%4f'%stats.amp, '最大耗时和最小耗时之差'],
['Stand deviation', '%.6f'%stats.stdev, '耗时标准差'],
['Request Per Second', '%d'%rps, '每秒的访问量']
]
results_table = AsciiTable(results_table_data, 'Rsults')
results_table.inner_row_border = True
print('\n')
print(results_table.table)
print('\r\r\n\n')
status_table_data = [
['Status Code', 'Items']
]
for code, items in self.status_code_counter.items():
status_table_data.append(['%d'%code, '%d'%len(items)])
status_table = AsciiTable(status_table_data, 'StausCode')
print(status_table.table)
示例5: print_download_item
# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import inner_row_border [as 别名]
def print_download_item(self, item, ascii_table):
dimensions = get_max_dimensions(ascii_table)
title = ""
for line in textwrap.wrap(
item.podcast.title,
dimensions[0][0],
initial_indent=' ',
subsequent_indent=' '):
title += line + "\n"
summ = ""
for line in textwrap.wrap(
item.summary,
dimensions[0][1],
initial_indent=' ',
subsequent_indent=' '):
summ += line + "\n"
if ascii_table:
ascii_table.table_data.append([title, summ])
print(ascii_table_last(ascii_table))
return ascii_table
else:
table_headers = [['title', 'summary']]
table_data = [[title, summ]]
ascii_table = AsciiTable(table_headers + table_data)
ascii_table.inner_row_border = True
print(ascii_table.table)
return ascii_table
示例6: print_table
# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import inner_row_border [as 别名]
def print_table(table_data):
table = AsciiTable(table_data)
table.inner_row_border = True
if table_data[:1] in ([['TITLE', 'IMDB RATING']],
[['TITLE', 'TOMATO RATING']]):
table.justify_columns[1] = 'center'
print("\n")
print(table.table)
示例7: print_matches
# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import inner_row_border [as 别名]
def print_matches(matches):
matches_arr = []
for match in matches:
#match_arr = [str(match[2]), str(match[3]), str(match[4]), str(match[5]), str(match[1])]
match_arr = [str(match[2]), str(match[3]), str(match[4]), str(match[5])]
matches_arr.append(match_arr)
#print (matches_array)
table = AsciiTable(matches_arr)
table.inner_heading_row_border = False
table.inner_row_border = True
print (table.table)
示例8: view_endpoints
# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import inner_row_border [as 别名]
def view_endpoints():
"""Lists the endpoints defined
Arguments:
*sort by service
*sort by stage
"""
table_data = [['Endpoint name', 'ip', 'pubport', 'url', 'mainservice', 'stackpointer', 'tree']]
for endpoint in session.query(Endpoint).all():
subtree = view_endpoint_tree(endpoint)
table_data.append([str(endpoint.name), str(endpoint.ip), str(endpoint.pubport), str(endpoint.url), str(endpoint.service.name), str(endpoint.stackpointer), subtree])
table = AsciiTable(table_data)
table.inner_row_border = True
print table.table
示例9: test_multi_line
# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import inner_row_border [as 别名]
def test_multi_line():
"""Test multi-lined cells."""
table_data = [
['Show', 'Characters'],
['Rugrats', 'Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille, Angelica Pickles,\nDil Pickles'],
['South Park', 'Stan Marsh, Kyle Broflovski, Eric Cartman, Kenny McCormick']
]
table = AsciiTable(table_data)
# Test defaults.
actual = table.table
expected = (
'+------------+-------------------------------------------------------------------------------------+\n'
'| Show | Characters |\n'
'+------------+-------------------------------------------------------------------------------------+\n'
'| Rugrats | Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille, Angelica Pickles, |\n'
'| | Dil Pickles |\n'
'| South Park | Stan Marsh, Kyle Broflovski, Eric Cartman, Kenny McCormick |\n'
'+------------+-------------------------------------------------------------------------------------+'
)
assert actual == expected
# Test inner row border.
table.inner_row_border = True
actual = table.table
expected = (
'+------------+-------------------------------------------------------------------------------------+\n'
'| Show | Characters |\n'
'+------------+-------------------------------------------------------------------------------------+\n'
'| Rugrats | Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille, Angelica Pickles, |\n'
'| | Dil Pickles |\n'
'+------------+-------------------------------------------------------------------------------------+\n'
'| South Park | Stan Marsh, Kyle Broflovski, Eric Cartman, Kenny McCormick |\n'
'+------------+-------------------------------------------------------------------------------------+'
)
assert actual == expected
# Justify right.
table.justify_columns = {1: 'right'}
actual = table.table
expected = (
'+------------+-------------------------------------------------------------------------------------+\n'
'| Show | Characters |\n'
'+------------+-------------------------------------------------------------------------------------+\n'
'| Rugrats | Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille, Angelica Pickles, |\n'
'| | Dil Pickles |\n'
'+------------+-------------------------------------------------------------------------------------+\n'
'| South Park | Stan Marsh, Kyle Broflovski, Eric Cartman, Kenny McCormick |\n'
'+------------+-------------------------------------------------------------------------------------+'
)
assert actual == expected
示例10: view_stack
# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import inner_row_border [as 别名]
def view_stack(service, stackname=None):
"""View the stack container version and position and tree points
Arguments:
service: service object
stackname: Name of stack if only one stack should be viewed
"""
table_data = [['Stackname', 'host', 'image', 'conatiners']]
for stack in service.stacks:
table_data.append([str(stack.name), str(stack.host), str(stack.image), "\n".join([c.name for c in stack.container])])
print table_data
table = AsciiTable(table_data)
table.inner_row_border = True
print table.table
示例11: list
# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import inner_row_border [as 别名]
def list(self, which):
if which == 'new':
self.print_summary_table()
# for item in EpisodeTable.select().where(EpisodeTable.new):
# self.print_summary(item.summary)
# print("\n")
if which == 'pod':
table_headers = [['id', 'title']]
table_data = []
for item in PodcastTable.select():
table_data.append([str(item.id), item.title])
ascii_table = AsciiTable(table_headers + table_data)
ascii_table.inner_row_border = True
print(ascii_table.table)
示例12: view_containers
# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import inner_row_border [as 别名]
def view_containers():
services = session.query(Service).all()
table = []
table.append(['Name', 'image', 'version', 'port', 'containerid'])
for service in services:
for stack in service.stacks:
for container in stack.container:
st = container.get_state()
table.append([str(st['name']), str(st['image']),
str(st['version']), str(st['port']),
str(st['containerid'])[0:15]])
t = AsciiTable(table)
t.inner_row_border = True
print t.table
示例13: list
# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import inner_row_border [as 别名]
def list(self):
"""
Get available stagers
Usage: list [-h]
"""
table_data = [
["Name", "Description"]
]
for l in self.loaded:
table_data.append([l.name, l.description])
table = AsciiTable(table_data, title="Available")
table.inner_row_border = True
print(table.table)
示例14: show_qualitative
# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import inner_row_border [as 别名]
def show_qualitative(baseline, predicted, ignore_types=False):
data = []
baseline_dict = map_id_to_field(baseline, "changes")
predicted_dict = map_id_to_field(predicted, "changes")
writings_dict = map_id_to_field(baseline, "text")
level_pred_dict = map_id_to_field(predicted, "level")
level_base_dict = map_id_to_field(baseline, "level")
nat_pred_dict = map_id_to_field(predicted, "nationality")
nat_base_dict = map_id_to_field(baseline, "nationality")
total_items = 0
precisions = collections.defaultdict(lambda: [])
recalls = collections.defaultdict(lambda: [])
precisions_per_nat = collections.defaultdict(lambda: [])
recalls_per_nat = collections.defaultdict(lambda: [])
precision_list = []
recall_list = []
for id_, text in writings_dict.items():
if id_ in predicted_dict:
text = format_text(text)
baseline = format_changes(baseline_dict[id_])
predicted = format_changes(predicted_dict.get(id_, []))
base = flatten2(id_, baseline_dict[id_], ignore_types)
prediction = flatten2(id_, predicted_dict.get(id_, []), ignore_types)
prec = "{}".format(precision(base, prediction))
rec = "{}".format(recall(base, prediction))
row = [id_, text, baseline, predicted, prec, rec]
data.append(row)
precision_list.append(float(prec))
recall_list.append(float(rec))
level = int(level_pred_dict.get(id_, level_base_dict.get(id_, 0)))
precisions[level].append(float(prec))
recalls[level].append(float(rec))
nat = nat_pred_dict.get(id_, nat_base_dict.get(id_, ''))
precisions_per_nat[nat].append(float(prec))
recalls_per_nat[nat].append(float(rec))
total_items += 1
data = sorted(data, key=lambda row: float(row[-2]), reverse=True)
headers = ["id", "text", "baseline", "predicted", "precision", "recall"]
data.insert(0, headers)
table = AsciiTable(data)
table.inner_row_border = True
print(table.table)
print("total items: ", total_items)
print("average precision: {} (std: {})".format(mean(precision_list), stdev(precision_list)))
print("average recall: {} (std: {})".format(mean(recall_list), stdev(recall_list)))
示例15: show_quantitative
# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import inner_row_border [as 别名]
def show_quantitative(annotated, predicted, ignore_types=False):
annotated = map_id_to_field(annotated, "changes")
predicted = map_id_to_field(predicted, "changes")
for id_ in list(annotated.keys()):
if id_ not in predicted:
del annotated[id_]
#top_missed_symbols(annotated, predicted)
annotated = flatten(annotated, ignore_types)
predicted = flatten(predicted, ignore_types)
data = [
["precision", "{}".format(precision(annotated, predicted))],
["recall", "{}".format(recall(annotated, predicted))]
]
table = AsciiTable(data)
table.inner_row_border = True
print(table.table)