本文整理汇总了Python中trac.util.embedded_numbers函数的典型用法代码示例。如果您正苦于以下问题:Python embedded_numbers函数的具体用法?Python embedded_numbers怎么用?Python embedded_numbers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了embedded_numbers函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_tags_or_branches
def _get_tags_or_branches(self, paths):
"""Retrieve known branches or tags."""
for path in self.options.get(paths, []):
if path.endswith("*"):
folder = posixpath.dirname(path)
try:
entries = [n for n in self.get_node(folder).get_entries()]
for node in sorted(entries, key=lambda n: embedded_numbers(n.path.lower())):
if node.kind == Node.DIRECTORY:
yield node
except: # no right (TODO: should use a specific Exception here)
pass
else:
try:
yield self.get_node(path)
except: # no right
pass
示例2: version_order
def version_order(v):
return (v.time or sys.maxint, embedded_numbers(v.name))
示例3: milestone_order
def milestone_order(m):
return (m.completed or sys.maxint,
m.due or sys.maxint,
embedded_numbers(m.name))
示例4: file_order
def file_order(a):
return (changes[a.rev].date,
embedded_numbers(a.name.lower()))
示例5: expand_macro
#.........这里部分代码省略.........
realms = list(set(all_realms)-set(self.exclude_realms))
if not realms:
return ''
query = '(%s) (%s)' % (query or '', ' or '.join(['realm:%s' % (r)
for r in realms]))
query_result = tag_system.query(req, query)
excludes = [exc.strip()
for exc in kw.get('exclude', '' ).split(':')
if exc.strip()]
if excludes and query_result:
filtered_result = [(resource, tags)
for resource, tags in query_result
if not any(fnmatchcase(resource.id, exc)
for exc in excludes)]
query_result = filtered_result
if not query_result:
return ''
def _link(resource):
if resource.realm == 'tag':
# Keep realm selection in tag links.
return builder.a(resource.id,
href=self.get_href(req, realms,
tag=resource))
elif resource.realm == 'ticket':
# Return resource link including ticket status dependend
# class to allow for common Trac ticket link style.
ticket = Ticket(env, resource.id)
return builder.a('#%s' % ticket.id,
class_=ticket['status'],
href=formatter.href.ticket(ticket.id),
title=shorten_line(ticket['summary']))
return render_resource_link(env, context, resource, 'compact')
if format == 'table':
cols = [col for col in cols.split('|')
if col in self.supported_cols]
# Use available translations from Trac core.
try:
labels = TicketSystem(env).get_ticket_field_labels()
labels['id'] = _('Id')
except AttributeError:
# Trac 0.11 neither has the attribute nor uses i18n.
labels = {'id': 'Id', 'description': 'Description'}
labels['realm'] = _('Realm')
labels['tags'] = _('Tags')
headers = [{'label': labels.get(col)}
for col in cols]
data.update({'cols': cols,
'headers': headers})
results = sorted(query_result, key=lambda r: \
embedded_numbers(to_unicode(r[0].id)))
results = self._paginate(req, results, realms)
rows = []
for resource, tags in results:
desc = tag_system.describe_tagged_resource(req, resource)
tags = sorted(tags)
wiki_desc = format_to_oneliner(env, context, desc)
if tags:
rendered_tags = [_link(Resource('tag', tag))
for tag in tags]
if 'oldlist' == format:
resource_link = _link(resource)
else:
resource_link = builder.a(wiki_desc,
href=get_resource_url(
env, resource, context.href))
if 'table' == format:
cells = []
for col in cols:
if col == 'id':
cells.append(_link(resource))
# Don't duplicate links to resource in both.
elif col == 'description' and 'id' in cols:
cells.append(wiki_desc)
elif col == 'description':
cells.append(resource_link)
elif col == 'realm':
cells.append(resource.realm)
elif col == 'tags':
cells.append(
builder([(tag, ' ')
for tag in rendered_tags]))
rows.append({'cells': cells})
continue
rows.append({'desc': wiki_desc,
'rendered_tags': None,
'resource_link': _link(resource)})
data.update({'format': format,
'paginator': results,
'results': rows,
'tags_url': req.href('tags')})
# Work around a bug in trac/templates/layout.html, that causes a
# TypeError for the wiki macro call, if we use add_link() alone.
add_stylesheet(req, 'common/css/search.css')
return Chrome(env).render_template(
req, 'listtagged_results.html', data, 'text/html', True)
示例6: blogpart_order
def blogpart_order(v):
return (v.time or utcmax, embedded_numbers(v.name))
示例7: file_order
def file_order(a):
return (changes[a.created_rev].author.lower(),
embedded_numbers(a.name.lower()))
示例8: repo_order
def repo_order((reponame, repoinfo, repos, youngest, err, href)):
return embedded_numbers(reponame.lower())
示例9: repo_order
def repo_order((reponame, repoinfo, repos, youngest, err)):
return (youngest and youngest.author.lower() or '',
embedded_numbers(reponame.lower()))
示例10: expand_macro
def expand_macro(self, formatter, name, content):
env = self.env
req = formatter.req
args, kw = parse_args(content)
# Use macro arguments (most likely wiki macro calls).
realms = 'realm' in kw and kw['realm'].split('|') or []
tag_system = TagSystem(env)
all_realms = [p.get_taggable_realm()
for p in tag_system.tag_providers]
self.all_realms = all_realms
self.realms = realms
if name == 'TagCloud':
args.append(' or '.join(['realm:%s' % r for r in realms]))
all_tags = tag_system.get_all_tags(req, ' '.join(args))
mincount = 'mincount' in kw and kw['mincount'] or None
return self.render_cloud(req, all_tags,
caseless_sort=self.caseless_sort,
mincount=mincount)
elif name == 'ListTagged':
if _OBSOLETE_ARGS_RE.search(content):
data = {'warning': 'obsolete_args'}
else:
data = {'warning': None}
context=formatter.context
# Use TagsQuery arguments (most likely wiki macro calls).
cols = 'cols' in kw and kw['cols'] or self.default_cols
format = 'format' in kw and kw['format'] or self.default_format
query = args and args[0].strip() or None
if query and not realms:
# First read query arguments (most likely a web-UI call).
for realm in all_realms:
if re.search('(^|\W)realm:%s(\W|$)' % (realm), query):
realms = realms and realms.append(realm) or [realm]
if not realms:
# Apply ListTagged defaults to macro call w/o realm.
realms = list(set(all_realms)-set(self.exclude_realms))
if not realms:
return ''
else:
self.query = query
self.realms = realms
query = '(%s) (%s)' % (query or '', ' or '.join(['realm:%s' % (r)
for r in realms]))
env.log.debug('LISTTAGGED_QUERY: ' + query)
query_result = tag_system.query(req, query)
if not query_result:
return ''
def _link(resource):
if resource.realm == 'tag':
# Keep realm selection in tag links.
return builder.a(resource.id,
href=self.get_href(req, tag=resource))
elif resource.realm == 'ticket':
# Return resource link including ticket status dependend
# class to allow for common Trac ticket link style.
ticket = Ticket(env, resource.id)
return builder.a('#%s' % ticket.id,
class_=ticket['status'],
href=formatter.href.ticket(ticket.id),
title=shorten_line(ticket['summary']))
return render_resource_link(env, context, resource, 'compact')
if format == 'table':
cols = [col for col in cols.split('|')
if col in self.supported_cols]
# Use available translations from Trac core.
try:
labels = TicketSystem(env).get_ticket_field_labels()
labels['id'] = _('Id')
except AttributeError:
# Trac 0.11 neither has the attribute nor uses i18n.
labels = {'id': 'Id', 'description': 'Description'}
labels['realm'] = _('Realm')
labels['tags'] = _('Tags')
headers = [{'label': labels.get(col)}
for col in cols]
data.update({'cols': cols,
'headers': headers})
results = sorted(query_result, key=lambda r: \
embedded_numbers(to_unicode(r[0].id)))
results = self._paginate(req, results)
rows = []
for resource, tags in results:
desc = tag_system.describe_tagged_resource(req, resource)
tags = sorted(tags)
if tags:
rendered_tags = [_link(Resource('tag', tag))
for tag in tags]
if 'oldlist' == format:
resource_link = _link(resource)
else:
desc = desc or \
get_resource_description(env, resource,
context=context)
resource_link = builder.a(desc, href=get_resource_url(
env, resource, context.href))
#.........这里部分代码省略.........
示例11: version_order
def version_order(v):
return (v.time or utcmax, embedded_numbers(v.name))
示例12: milestone_order
def milestone_order(m):
return (m.completed or utcmax,
m.due or utcmax,
embedded_numbers(m.name))
示例13: name_order
def name_order(entry):
return embedded_numbers(entry.name)
示例14: file_order
def file_order(a):
return (a['content_length'],
embedded_numbers(a['name'].lower()))
示例15: kind_order
def kind_order(entry):
return (not entry['id'], embedded_numbers(entry['id']))