本文整理汇总了Python中trac.util.text.print_table函数的典型用法代码示例。如果您正苦于以下问题:Python print_table函数的具体用法?Python print_table怎么用?Python print_table使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_table函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _do_list
def _do_list(self):
print_table([(m.name, m.due and
format_date(m.due, console_date_format),
m.completed and
format_datetime(m.completed, console_datetime_format))
for m in model.Milestone.select(self.env)],
[_("Name"), _("Due"), _("Completed")])
示例2: _do_list
def _do_list(self):
print_table(
[(title, int(edits), format_datetime(from_utimestamp(modified),
console_datetime_format))
for title, edits, modified in self.env.db_query("""
SELECT name, max(version), max(time)
FROM wiki GROUP BY name ORDER BY name""")
], [_("Title"), _("Edits"), _("Modified")])
示例3: _do_list
def _do_list(self, realm=None):
fts = FullTextSearch(self.env)
realms = realm and [realm] or fts.index_realms
fields = ['realm', 'id']
query, response = fts._do_search('*', realms, sort_by=fields,
field_limit=fields)
rows = ((doc['realm'], doc['id']) for doc in fts._docs(query))
print_table(rows, (_("Realm"), _("Id")))
示例4: _list_expired
def _list_expired(self, when=None):
# Parse optional date argument
when = when if when is None else datetime.strptime(when, '%Y-%m-%d')
userstore = get_userstore()
users = [(user.username, user.expires) for user in userstore.get_expired_users(when=when)]
print_table(users, ('User', 'Expires'))
示例5: _do_list
def _do_list(self):
rm = RepositoryManager(self.env)
values = []
for (reponame, info) in sorted(rm.get_all_repositories().iteritems()):
alias = ""
if "alias" in info:
alias = info["alias"] or "(default)"
values.append((reponame or "(default)", info.get("type", ""), alias, info.get("dir", "")))
print_table(values, [_("Name"), _("Type"), _("Alias"), _("Directory")])
示例6: _do_list
def _do_list(self, *sids):
if not sids:
sids = ['*']
print_table([(r[0], r[1], format_date(to_datetime(r[2]),
console_date_format),
r[3], r[4])
for r in self._get_list(sids)],
[_('SID'), _('Auth'), _('Last Visit'), _('Name'),
_('Email')])
示例7: _do_list
def _do_list(self):
rm = RepositoryManager(self.env)
values = []
for (reponame, info) in sorted(rm.get_all_repositories().iteritems()):
alias = ''
if 'alias' in info:
alias = info['alias'] or '(default)'
values.append((reponame or '(default)', info.get('type', ''),
alias, info.get('dir', '')))
print_table(values, [_('Name'), _('Type'), _('Alias'), _('Directory')])
示例8: _do_list
def _do_list(self):
db = self.env.get_db_cnx()
cursor = db.cursor()
cursor.execute("SELECT name, max(version), max(time) "
"FROM wiki GROUP BY name ORDER BY name")
print_table([(r[0], int(r[1]),
format_datetime(from_utimestamp(r[2]),
console_datetime_format))
for r in cursor],
[_('Title'), _('Edits'), _('Modified')])
示例9: do_transaction
def do_transaction(db):
if name.endswith('*'):
pages = list(WikiSystem(self.env).get_pages(name.rstrip('*')
or None))
for p in pages:
page = model.WikiPage(self.env, p, db=db)
page.delete()
print_table(((p,) for p in pages), [_('Deleted pages')])
else:
page = model.WikiPage(self.env, name, db=db)
page.delete()
示例10: _do_remove
def _do_remove(self, name):
with self.env.db_transaction:
if name.endswith('*'):
pages = list(WikiSystem(self.env).get_pages(name.rstrip('*')
or None))
for p in pages:
page = model.WikiPage(self.env, p)
page.delete()
print_table(((p,) for p in pages), [_('Deleted pages')])
else:
page = model.WikiPage(self.env, name)
page.delete()
示例11: _do_list
def _do_list(self):
# Get downloads API component.
api = self.env[DownloadsApi]
# Create context.
context = Context('downloads-consoleadmin')
db = self.env.get_db_cnx()
context.cursor = db.cursor()
# Print uploded download
downloads = api.get_downloads(context)
print_table([(download['id'], download['file'], pretty_size(
download['size']), format_datetime(download['time']), download['component'], download['version'],
download['platform']['name'], download['type']['name']) for download in downloads], ['ID',
'Filename', 'Size', 'Uploaded', 'Component', 'Version', 'Platform', 'Type'])
示例12: _do_list
def _do_list(self, user=None):
permsys = PermissionSystem(self.env)
if user:
rows = []
perms = permsys.get_user_permissions(user)
for action in perms:
if perms[action]:
rows.append((user, action))
else:
rows = permsys.get_all_permissions()
rows.sort()
print_table(rows, [_('User'), _('Action')])
print
printout(_("Available actions:"))
actions = permsys.get_actions()
actions.sort()
text = ', '.join(actions)
printout(wrap(text, initial_indent=' ', subsequent_indent=' ',
linesep='\n'))
print
示例13: _validate_print_table
def _validate_print_table(self, expected, data, **kwargs):
out = StringIO()
kwargs["out"] = out
print_table(data, **kwargs)
self.assertEqual(expected.encode("utf-8"), strip_line_ws(out.getvalue(), leading=False))
示例14: cli_report
def cli_report(self):
infos_dic = self._getTracVolume()
infos = [(n, infos_dic[n]) for n in infos_dic]
infos.sort
print_table(infos, (_("type"), _("volume")))
示例15: _display_status
def _display_status(self):
print "Env is " + self.env
print_table([self.greetings])