def display_sql(cursor,title,header,padd):
col_names = [cn[0].upper() for cn in cursor.description]
rows = cursor.fetchall()
sqlr = prettytable.PrettyTable()
sqlr.header = header
sqlr.padding_width = padd
sqlr.hrules = prettytable.ALL
sqlr.vrules = prettytable.ALL
sqlr.title = title
row_id = -1
for name in col_names:
row_id += 1
sqlr.add_column(name, [row[row_id] for row in rows])
return sqlr
# MCE Version Header
python类ALL的实例源码
def print_permissions(account):
t = PrettyTable(["Permission", "Threshold", "Key/Account"], hrules=allBorders)
t.align = "r"
for permission in ["owner", "active"]:
auths = []
# account auths:
for authority in account[permission]["account_auths"]:
auths.append("%s (%d)" % (Account(authority[0])["name"], authority[1]))
# key auths:
for authority in account[permission]["key_auths"]:
auths.append("%s (%d)" % (authority[0], authority[1]))
t.add_row([
permission,
account[permission]["weight_threshold"],
"\n".join(auths),
])
print(t)
def print_permissions(account):
t = PrettyTable(["Permission", "Threshold", "Key/Account"], hrules=allBorders)
t.align = "r"
for permission in ["owner", "active"]:
auths = []
# account auths:
for authority in account[permission]["account_auths"]:
auths.append("%s (%d)" % (Account(authority[0])["name"], authority[1]))
# key auths:
for authority in account[permission]["key_auths"]:
auths.append("%s (%d)" % (authority[0], authority[1]))
t.add_row([
permission,
account[permission]["weight_threshold"],
"\n".join(auths),
])
click.echo(t)
def print_permissions(account):
t = PrettyTable(["Permission", "Threshold", "Key/Account"], hrules=allBorders)
t.align = "r"
for permission in ["owner", "active"]:
auths = []
# account auths:
for authority in account[permission]["account_auths"]:
auths.append("%s (%d)" % (Account(authority[0])["name"], authority[1]))
# key auths:
for authority in account[permission]["key_auths"]:
auths.append("%s (%d)" % (authority[0], authority[1]))
t.add_row([
permission,
account[permission]["weight_threshold"],
"\n".join(auths),
])
print(t)
def __init__(self,redis,server,play_objec,data,ctx=None,bot=None):
#RPG Variable
self.redis=redis
self.ctx=ctx
self.server=server
self.player = play_objec
self.player_id=self.player.id
self.credit= int(data.get("credit",100))
self.health = int(data.get("hp",100))
self.total_health = self.health
self.mana = int(data.get("mana",100))
self.total_mana = self.mana
self.data = data
self.profile="{}:Rpg:{}:".format(server,self.player.id) + "{}"
self.bot = bot
self.table = PrettyTable()
self.table.hrules=prettytable.ALL
self.table.vertical_char="?"
self.table.horizontal_char="?"
self.table.junction_char="?"
# print(data)
def mc_table(row_col_names,header,padd) :
pt = prettytable.PrettyTable(row_col_names)
pt.header = header # Boolean
pt.padding_width = padd
pt.hrules = prettytable.ALL
pt.vrules = prettytable.ALL
pt_empty = str(pt)
return pt,pt_empty
def ext_table(row_col_names,header,padd) :
pt = prettytable.PrettyTable(row_col_names)
pt.header = header # Boolean
pt.padding_width = padd
pt.hrules = prettytable.ALL
pt.vrules = prettytable.ALL
return pt
# Detect DB version
def _mk_tbl(fields):
tbl = prettytable.PrettyTable(fields, left_padding_width=1, right_padding_width=1, hrules=prettytable.ALL)
col_max_width = (terminalsize()[0] / len(fields)) - 5
for k in tbl.align:
tbl.align[k] = 'l'
return (tbl, col_max_width)
def print_permissions(account):
t = PrettyTable(["Permission", "Threshold", "Key/Account"], hrules=allBorders)
t.align = "r"
for permission in ["owner", "active", "posting"]:
auths = []
for type_ in ["account_auths", "key_auths"]:
for authority in account[permission][type_]:
auths.append("%s (%d)" % (authority[0], authority[1]))
t.add_row([
permission,
account[permission]["weight_threshold"],
"\n".join(auths),
])
print(t)
def print_permissions(account):
t = PrettyTable(["Permission", "Threshold", "Key/Account"], hrules=allBorders)
t.align = "r"
for permission in ["owner", "active", "posting"]:
auths = []
for type_ in ["account_auths", "key_auths"]:
for authority in account[permission][type_]:
auths.append("%s (%d)" % (authority[0], authority[1]))
t.add_row([
permission,
account[permission]["weight_threshold"],
"\n".join(auths),
])
print(t)