本文整理匯總了Python中texttable.Texttable方法的典型用法代碼示例。如果您正苦於以下問題:Python texttable.Texttable方法的具體用法?Python texttable.Texttable怎麽用?Python texttable.Texttable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類texttable
的用法示例。
在下文中一共展示了texttable.Texttable方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: autodoc_fields
# 需要導入模塊: import texttable [as 別名]
# 或者: from texttable import Texttable [as 別名]
def autodoc_fields(declaration_cls, model_cls):
"""Produces autodocumentation table for the fields.
Exposed as a function in order to be reusable by a simple export,
e.g., from anyblok.mixin.
"""
if not has_sql_fields([model_cls]):
return ''
rows = [['Fields', '']]
rows.extend([x, y.autodoc()]
for x, y in get_fields(model_cls).items())
table = Texttable(max_width=0)
table.set_cols_valign(["m", "t"])
table.add_rows(rows)
return table.draw() + '\n\n'
示例2: pretty_print_special
# 需要導入模塊: import texttable [as 別名]
# 或者: from texttable import Texttable [as 別名]
def pretty_print_special(rows, headers, sizes=False, align=False, email=False):
try:
tab = tt.Texttable()
if email:
tab.set_deco(tt.Texttable.HEADER)
tab.add_rows(rows)
if sizes:
tab.set_cols_width(sizes)
if align:
tab.set_cols_align(align)
tab.header(headers)
print('\n')
print(tab.draw())
except Exception as e:
print('Report me plz')
print(e)
示例3: format_for_console
# 需要導入模塊: import texttable [as 別名]
# 或者: from texttable import Texttable [as 別名]
def format_for_console(cls, data):
success_vals = []
duration_vals = []
count = 0
for res in data[0]:
msgs, success, duration = res.raw_result.strip().split('\n')
count += int(msgs)
success_vals.append(float(success))
duration_vals.append(float(duration))
totalt = max(duration_vals)
totalms = int(count / totalt)
sucesst = int(sum(success_vals) / len(success_vals))
tab = texttable.Texttable(max_width=120)
tab.set_deco(tab.HEADER | tab.VLINES | tab.BORDER)
tab.header(["Bandwidth m/s", "Success %"])
tab.add_row([totalms, sucesst])
return tab.draw()
示例4: generation_tab_printer
# 需要導入模塊: import texttable [as 別名]
# 或者: from texttable import Texttable [as 別名]
def generation_tab_printer(read_times, generation_times):
"""
Function to print the time logs in a nice tabular format.
:param read_times: List of reading times.
:param generation_times: List of generation times.
"""
t = Texttable()
t.add_rows([["Metric", "Value"],
["Mean graph read time:", np.mean(read_times)],
["Standard deviation of read time.", np.std(read_times)]])
print(t.draw())
t = Texttable()
t.add_rows([["Metric", "Value"],
["Mean sequence generation time:", np.mean(generation_times)],
["Standard deviation of generation time.", np.std(generation_times)]])
print(t.draw())
示例5: printFeeds
# 需要導入模塊: import texttable [as 別名]
# 或者: from texttable import Texttable [as 別名]
def printFeeds():
table = texttable.Texttable()
table.set_deco(texttable.Texttable.HEADER)
table.set_cols_dtype(['i', # int
't',]) # text
table.header(["ID", "URL"])
# Connect
db.connection()
for row in Feeds.select():
table.add_row([row.feedid, row.url])
# Close connection
db.close()
logging.info(table.draw())
示例6: printFilters
# 需要導入模塊: import texttable [as 別名]
# 或者: from texttable import Texttable [as 別名]
def printFilters():
table = texttable.Texttable()
table.set_deco(texttable.Texttable.HEADER)
table.set_cols_dtype(['i', # int
't',]) # text
table.header(["ID", "FILTER"])
# Connect
db.connection()
for row in Filter.select():
table.add_row([row.filterid, row.filtervalue])
# Close connection
db.close()
logging.info(table.draw())
示例7: printUsers
# 需要導入模塊: import texttable [as 別名]
# 或者: from texttable import Texttable [as 別名]
def printUsers():
table = texttable.Texttable()
table.set_deco(texttable.Texttable.HEADER)
table.set_cols_dtype(['i', # int
't',
't',
't',
't']) # text
table.header(["ID", "USERNAME", "EMAIL", "KINDLE EMAIL", "SEND EBOOK"])
db.connection()
for user in User.select():
if user.sendtokindle == 1:
sendstatus = "YES"
else:
sendstatus = "NO"
table.add_row([user.userid, user.name, user.email, user.kindle_mail, sendstatus])
db.close()
logging.info(table.draw())
示例8: resources
# 需要導入模塊: import texttable [as 別名]
# 或者: from texttable import Texttable [as 別名]
def resources(args):
from texttable import Texttable
client = cloudformation_client()
paginator = client.get_paginator("list_stack_resources").paginate(StackName=args.stack)
table = Texttable(max_width=150)
table.add_rows([RESOURCE_HEADERS])
for page in paginator:
for resource in page["StackResourceSummaries"]:
table.add_row(
[
resource["LogicalResourceId"],
resource["PhysicalResourceId"],
resource["ResourceType"],
resource["ResourceStatus"],
]
)
logger.info(table.draw() + "\n")
示例9: __generate_table
# 需要導入模塊: import texttable [as 別名]
# 或者: from texttable import Texttable [as 別名]
def __generate_table(header, current, new):
changes = DeepDiff(current, new, ignore_order=False, report_repetition=True, verbose_level=2, view="tree")
table = Texttable(max_width=200)
table.set_cols_dtype(["t", "t", "t", "t"])
table.add_rows([["Path", "From", "To", "Change Type"]])
print_diff = False
processed_changes = __collect_changes(changes)
for change in processed_changes:
print_diff = True
path = re.findall("\\['?([\\w-]+)'?\\]", change.path)
table.add_row([" > ".join(path), change.before, change.after, change.type.title().replace("_", " ")])
logger.info(header + " Diff:")
if print_diff:
logger.info(table.draw() + "\n")
else:
logger.info("No Changes found" + "\n")
示例10: display
# 需要導入模塊: import texttable [as 別名]
# 或者: from texttable import Texttable [as 別名]
def display(i, names: list, descriptions: list, values: list):
for k in i:
names.append(k)
descriptions.append(i[k][0])
values.append(i[k][1])
t = table.Texttable()
headings = ["Name", "Desc.", "Val"]
t.header(headings)
#t.set_chars(["-"," ","+","~"])
t.set_deco(table.Texttable.BORDER)
for row in zip(names, descriptions, values):
t.add_row(row)
s = t.draw()
print(s + "\n")
return names, descriptions, values
示例11: do_info
# 需要導入模塊: import texttable [as 別名]
# 或者: from texttable import Texttable [as 別名]
def do_info(self, args):
try:
#call UForge API
printer.out("Getting user ["+self.login+"] ...")
user = self.api.Users(self.login).Get()
if user is None:
printer.out("user "+ self.login +"does not exist", printer.ERROR)
else:
table = Texttable(200)
table.set_cols_align(["c", "l", "c", "c", "c", "c", "c", "c"])
table.header(["Login", "Email", "Lastname", "Firstname", "Created", "Active", "Promo Code", "Creation Code"])
table.add_row([user.loginName, user.email, user.surname , user.firstName, user.created.strftime("%Y-%m-%d %H:%M:%S"), "X", user.promoCode, user.creationCode])
print table.draw() + "\n"
return 0
except ArgumentParserError as e:
printer.out("ERROR: In Arguments: "+str(e), printer.ERROR)
self.help_info()
except Exception as e:
return handle_uforge_exception(e)
示例12: do_list
# 需要導入模塊: import texttable [as 別名]
# 或者: from texttable import Texttable [as 別名]
def do_list(self, args):
try:
#call UForge API
printer.out("Getting all your bundles ...")
bundles = self.api.Users(self.login).Mysoftware.Getall()
bundles = bundles.mySoftwareList.mySoftware
if bundles is None or len(bundles) == 0:
printer.out("No bundles available")
else:
table = Texttable(800)
table.set_cols_dtype(["t","t","t", "t","t","t","t"])
table.header(["Id", "Name", "Version", "Description", "Category", "Size", "Imported"])
bundles = generics_utils.order_list_object_by(bundles, "name")
for bundle in bundles:
category = ""
if bundle.category is not None:
category = bundle.category.name
table.add_row([bundle.dbId, bundle.name, bundle.version, bundle.description, category, size(bundle.size), "X" if bundle.imported else ""])
print table.draw() + "\n"
printer.out("Found "+str(len(bundles))+" bundles")
return 0
except Exception as e:
return handle_uforge_exception(e)
示例13: tab_printer
# 需要導入模塊: import texttable [as 別名]
# 或者: from texttable import Texttable [as 別名]
def tab_printer(args):
"""
Function to print the logs in a nice tabular format.
:param args: Parameters used for the model.
"""
args = vars(args)
t = Texttable()
t.add_rows([["Parameter", "Value"]])
t.add_rows([[k.replace("_", " ").capitalize(), v] for k, v in args.items()])
print(t.draw())
示例14: tab_printer
# 需要導入模塊: import texttable [as 別名]
# 或者: from texttable import Texttable [as 別名]
def tab_printer(args):
"""
Function to print the logs in a nice tabular format.
:param args: Parameters used for the model.
"""
args = vars(args)
keys = sorted(args.keys())
t = Texttable()
t.add_rows([["Parameter", "Value"]])
t.add_rows([[k.replace("_", " ").capitalize(), args[k]] for k in keys])
print(t.draw())
示例15: score_printer
# 需要導入模塊: import texttable [as 別名]
# 或者: from texttable import Texttable [as 別名]
def score_printer(logs):
"""
Print the performance for every 10th epoch on the test dataset.
:param logs: Log dictionary.
"""
t = Texttable()
t.add_rows([per for i, per in enumerate(logs["performance"]) if i % 10 == 0])
print(t.draw())