本文整理汇总了Python中texttable.Texttable.set_chars方法的典型用法代码示例。如果您正苦于以下问题:Python Texttable.set_chars方法的具体用法?Python Texttable.set_chars怎么用?Python Texttable.set_chars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类texttable.Texttable
的用法示例。
在下文中一共展示了Texttable.set_chars方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: toString
# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import set_chars [as 别名]
def toString(self):
table = Texttable()
table.set_chars(['-','|','+','-'])
rows = []
for i in range(0, self.size):
row = []
for j in range(0, self.size):
row.append("x" if (i, j) in self.cells else "o")
rows.append(row)
table.add_rows(rows)
return table.draw()
示例2: __str__
# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import set_chars [as 别名]
def __str__(self):
from ..formatters import to_format
table = Texttable(max_width=0)
table.set_chars(self.__border__())
data = self.to_array()
for sub_array in data:
new_array = []
for item in sub_array:
if item == "":
new_array.append(" ")
else:
new_array.append(to_format(str, item))
table.add_row(new_array)
return table.draw()
示例3: service_table
# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import set_chars [as 别名]
def service_table(services, width):
table = Texttable(max_width=width)
headers = ['uuid', 'state', 'instance', 'ip', 'service', 'scale']
rows = []
for service in services:
rows.append([
service['uuid'],
service['state'],
service['instance'],
service['ip'],
service['service'],
service['scale']
])
table.set_chars(['-', '|', '+', '-'])
table.add_rows([headers] + rows)
return table.draw()
示例4: repr_full
# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import set_chars [as 别名]
def repr_full(self, connection):
"""Full representation of a connection"""
t = Texttable(78)
t.set_deco(Texttable.HEADER | Texttable.VLINES)
t.set_chars(['.', '|', 'o', '-'])
t.header(['Field', 'Client', 'Server'])
t.set_cols_align(['r', 'l', 'l'])
t.add_row(['IP', connection.client_ip, connection.server_ip])
t.add_row(['Port', connection.client_port, connection.server_port])
t.add_row(['Datagrams', connection.client_sent_nb_datagrams,
connection.server_sent_nb_datagrams])
t.add_row(['Datagrams (bytes)', connection.client_sent_len,
connection.server_sent_len])
r = (
'Connection %d\n%s'
'Start date: %s\n'
'Duration: %s'
) % (
connection.nb, '' if connection.ssh else C.FMag +
'Not detected as a ssh connection' + C.FRes + '\n',
connection.start_time.strftime('%b %d, %Y - %H:%M:%S'),
str_td(connection.duration)
)
for plugin in self.plugins:
plugin_results = self.result_plugin(connection, plugin)
for field_short, field_client, field_server \
in self.plugins_fields_table[plugin]:
if field_client not in plugin_results \
or plugin_results[field_client] is None:
plugin_results[field_client] = ''
if field_server not in plugin_results \
or plugin_results[field_server] is None:
plugin_results[field_server] = ''
if plugin_results[field_client] != '' \
or plugin_results[field_server] != '':
t.add_row([
field_short,
C.remove_color(plugin_results[field_client]),
C.remove_color(plugin_results[field_server])
])
del(plugin_results[field_client])
del(plugin_results[field_server])
for field in self.plugins_fields[plugin]:
if field in plugin_results:
r += '\n%s: %s' % (field, plugin_results[field])
r += '\n%s' % t.draw()
print '%s\n' % r.replace('\n', '\n ')
示例5: instance_table
# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import set_chars [as 别名]
def instance_table(instances, width):
table = Texttable(max_width=width)
headers = ['uuid', 'state', 'ip', 'size', 'group', 'scale', 'region']
rows = []
for instance in instances:
rows.append([
instance['uuid'],
instance['state'],
instance['ip'],
instance['size'],
instance['group'],
instance['scale'],
instance['region']
])
table.set_chars(['-', '|', '+', '-'])
table.add_rows([headers] + rows)
return table.draw()
示例6: render_text_table
# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import set_chars [as 别名]
def render_text_table(sheet, _, write_title):
content = ""
if write_title:
content += "%s:\n" % sheet.name
table = Texttable(max_width=0)
data = sheet.to_array()
table.set_cols_dtype(['t'] * len(data[0]))
if len(sheet.colnames) > 0:
table.set_chars(['-', '|', '+', '='])
table.header(list(_cleanse_a_row(data[0])))
else:
table.add_row(list(_cleanse_a_row(data[0])))
for sub_array in data[1:]:
new_array = _cleanse_a_row(sub_array)
table.add_row(list(new_array))
content += table.draw()
return content
示例7: __str__
# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import set_chars [as 别名]
def __str__(self):
from ..formatters import to_format
ret = "Sheet Name: %s\n" % self.name
if len(self.colnames) > 0:
table = Texttable(max_width=0)
table.set_chars(self.__border__())
data = self.to_array()
new_data = []
for sub_array in data:
new_array = []
for item in sub_array:
if item == "":
new_array.append(" ")
else:
new_array.append(to_format(str,item))
new_data.append(new_array)
table.add_rows(new_data)
return ret+table.draw()
else:
return ret+FilterableSheet.__str__(self)
示例8: _print_results_table
# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import set_chars [as 别名]
def _print_results_table(self, results):
"""Print results formatted in a table.
"""
table = Texttable()
table.set_chars(['-', '|', '+', '-'])
table.set_deco(Texttable.BORDER | Texttable.HEADER | Texttable.VLINES)
header_type = ['t', 't']
header = ['Auther', 'Title']
if self._configuration['list']['isbn'] or self._arguments['-i']:
header_type += ['t']
header += ['Isbn']
table.set_cols_dtype(header_type)
table.header(header)
for author, title, isbn in results:
if isbn is None:
isbn = ""
row = [author.encode('utf-8'), title.encode('utf-8')]
if self._configuration['list']['isbn'] or self._arguments['-i']:
row += [isbn.encode('utf-8')]
table.add_row(row)
self.out(table.draw())
示例9: render_text_table
# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import set_chars [as 别名]
def render_text_table(sheet, write_title):
"""return data in text table presentation"""
content = ""
if write_title:
content += "%s:\n" % sheet.name
table = Texttable(max_width=0)
data = sheet.to_array()
if isinstance(data, GeneratorType):
data = list(data)
if len(data) == 0:
return content
table.set_cols_dtype(['t'] * len(data[0]))
if len(sheet.colnames) > 0:
table.set_chars(['-', '|', '+', '='])
table.header(list(_cleanse_a_row(data[0])))
else:
table.add_row(list(_cleanse_a_row(data[0])))
for sub_array in data[1:]:
new_array = _cleanse_a_row(sub_array)
table.add_row(list(new_array))
content += table.draw()
return content
示例10: Texttable
# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import set_chars [as 别名]
'''
Just a small example on how to use the Refprop class to calculate a power cycle.
This file employs a working fluid mixture at supercritical conditions.
'''
from texttable import Texttable
# Define output routines for pretty-printing
pointsTable = Texttable()
pointsTable.set_deco(Texttable.HEADER)
pointsTable.set_chars(['-', '|', '+', '='])
pointsTable.set_cols_dtype(['t', # text
'f', # float (decimal)
'f', # float (decimal)
'f', # float (decimal)
'f']) # float (decimal)
pointsTable.set_cols_align(["l", "r", "r", "r", "r"])
pointsTable.set_cols_valign(["t", "m", "m", "m", "m"])
#pointsTable.set_cols_width([10, 12, 13, 13, 13])
pointsTable.header(["Point","Temperature, C","Pressure, bar","Enthalpy, kJ/kg","Entropy, kJ/kg-K"])
# Define output routines for pretty-printing
paramsTable = Texttable()
paramsTable.set_deco(Texttable.HEADER)
paramsTable.set_chars(['-', '|', '+', '='])
paramsTable.set_cols_dtype(['t', # text
'f', # float (decimal)
't']) # text
paramsTable.set_cols_align(["l", "r", "l"])
paramsTable.set_cols_valign(["t", "m", "m"])
#paramsTable.set_cols_width([20, 15, 15])
paramsTable.header(["Parameter","Value","Unit"])