Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_genshi_builder():
"""Genshi template + tag builder"""
stream = tag.TABLE([
tag.tr([tag.td(c) for c in row.values()])
for row in table
]).generate()
stream = genshi_tmpl2.generate(table=stream)
stream.render('html', strip_whitespace=False)
def make_list(items):
parts = [item.rsplit('.', 1) for item in items]
return tag.table(tag.tbody(
tag.tr(tag.td(c, class_='trac-name'),
tag.td('(%s.*)' % m, class_='trac-name'))
for m, c in parts), class_='trac-pluglist')
revs_link(removed, old_context)),
added_ni and tag(added_ni_label,
revs_link(added_ni, new_context)),
removed_ni and tag(removed_ni_label,
revs_link(removed_ni, old_context))
))
# Go through remaining old sources, those were deleted
removed_sources = []
for spath, old_revs in old_sources.iteritems():
removed_sources.append((spath,
_get_source_link(spath, old_context)))
if modified_sources or removed_sources:
modified_sources.sort()
removed_sources.sort()
changes = tag.table(tag.tbody(
[tag.tr(tag.td(c) for c in cols[1:])
for cols in modified_sources],
[tag.tr(tag.td(src), tag.td(_('removed'), colspan=4))
for spath, src in removed_sources]), class_='props')
else:
changes = tag.em(_(' (with no actual effect on merging)'))
return tag.li(tag_('Property %(prop)s changed', prop=tag.strong(name)),
changes)
def expand_macro(self, formatter, name, content):
interwikis = []
for k in sorted(self.keys()):
prefix, url, title = self[k]
interwikis.append({
'prefix': prefix, 'url': url, 'title': title,
'rc_url': self._expand_or_append(url, ['RecentChanges']),
'description': url if title == prefix else title})
return tag.table(tag.tr(tag.th(tag.em("Prefix")),
tag.th(tag.em("Site"))),
[tag.tr(tag.td(tag.a(w['prefix'], href=w['rc_url'])),
tag.td(tag.a(w['description'],
href=w['url'])))
for w in interwikis ],
class_="wiki interwiki")
from trac.mimeview.api import Mimeview
mime_map = Mimeview(self.env).mime_map
mime_type_filter = ''
args, kw = parse_args(args)
if args:
mime_type_filter = args.pop(0).strip().rstrip('*')
mime_types = {}
for key, mime_type in mime_map.iteritems():
if (not mime_type_filter or
mime_type.startswith(mime_type_filter)) and key != mime_type:
mime_types.setdefault(mime_type, []).append(key)
return tag.div(class_='mimetypes')(
tag.table(class_='wiki')(
tag.thead(tag.tr(
tag.th(_("MIME Types")), # always use plural
tag.th(tag.a("WikiProcessors",
href=formatter.context.href.wiki(
'WikiProcessors'))))),
tag.tbody(
tag.tr(tag.th(tag.tt(mime_type),
style="text-align: left"),
tag.td(tag.code(
' '.join(sorted(mime_types[mime_type])))))
for mime_type in sorted(mime_types.keys()))))