本文整理汇总了Python中genshi.filters.Transformer.before方法的典型用法代码示例。如果您正苦于以下问题:Python Transformer.before方法的具体用法?Python Transformer.before怎么用?Python Transformer.before使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类genshi.filters.Transformer
的用法示例。
在下文中一共展示了Transformer.before方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: filter_stream
# 需要导入模块: from genshi.filters import Transformer [as 别名]
# 或者: from genshi.filters.Transformer import before [as 别名]
def filter_stream(self, req, method, filename, stream, data):
if re.match(r'^/(changeset|browser|attachment/ticket/\d+/.?).*',
req.path_info):
filter = Transformer('//h1')
button = self._subscription_button(req.path_info,
req.args.get('rev'))
stream |= filter.before(button)
return stream
示例2: filter_stream
# 需要导入模块: from genshi.filters import Transformer [as 别名]
# 或者: from genshi.filters.Transformer import before [as 别名]
def filter_stream(self, req, method, filename, stream, data):
if 'TICKET_ADMIN' in req.perm and req.path_info.startswith('/admin/ticket/components'):
if data.get('components'):
filter = Transformer('//form[@id="addcomponent"]/fieldset/div[@class="buttons"]')
stream = stream | filter.before(tag.div("Default CC:",
tag.br(),
tag.input(type='text', name='defaultcc'),
class_='field'))
default_ccs = DefaultCC.select(self.env)
stream = stream | Transformer('//table[@id="complist"]/thead/tr') \
.append(tag.th('Default CC'))
filter = Transformer('//table[@id="complist"]/tbody')
default_comp = self.config.get('ticket', 'default_component')
for comp in data.get('components'):
if comp.name == default_comp:
default_tag = tag.input(type='radio', name='default', value=comp.name, checked='checked')
else:
default_tag = tag.input(type='radio', name='default', value=comp.name)
if comp.name in default_ccs:
default_cc = default_ccs[comp.name]
else:
default_cc = ''
filter = filter.append(tag.tr(tag.td(tag.input(type='checkbox', name='sel', value=comp.name), class_='sel'),
tag.td(tag.a(comp.name, href=req.href.admin('ticket', 'components') + '/' + comp.name), class_='name'),
tag.td(comp.owner, class_='owner'),
tag.td(default_tag, class_='default'),
tag.td(default_cc, class_='defaultcc')))
return stream | filter
elif data.get('component'):
cc = DefaultCC(self.env, data.get('component').name)
filter = Transformer('//form[@id="modcomp"]/fieldset/div[@class="buttons"]')
filter = filter.before(tag.div("Default CC:",
tag.br(),
tag.input(type='text', name='defaultcc', value=cc.cc),
class_='field')) \
.before(tag.input(type='hidden', name='old_name', value=cc.name))
return stream | filter
return stream
示例3: filter_stream
# 需要导入模块: from genshi.filters import Transformer [as 别名]
# 或者: from genshi.filters.Transformer import before [as 别名]
def filter_stream(self, req, method, filename, stream, data):
if filename == "roadmap.html":
sortcrit = self._get_settings(req, "sortcrit", self.criterias[0])
sortdirect = self._get_settings(req, "sortdirect", self.directions[0])
sel = ' selected = "selected"'
html_str = "<div>" + _("Sort by: ")
html_str += '<select name="sortcrit">'
for crit in self.criterias:
html_str += '<option value ="%s" %s>%s</option>' % (crit, sel if sortcrit == crit else "", _(crit))
html_str += "</select>"
html_str += '<select name="sortdirect">'
for dir in self.directions:
html_str += '<option value ="%s" %s>%s</option>' % (dir, sel if sortdirect == dir else "", _(dir))
html_str += "</select></div>"
html = HTML(html_str)
filter = Transformer('//form[@id="prefs"]/div[@class="buttons"]')
return stream | filter.before(html)
return stream
示例4: filter_stream
# 需要导入模块: from genshi.filters import Transformer [as 别名]
# 或者: from genshi.filters.Transformer import before [as 别名]
def filter_stream(self, req, method, filename, stream, data):
if 'TICKET_ADMIN' in req.perm and \
req.path_info.startswith('/admin/ticket/components'):
if data.get('component'):
cc = DefaultCC(self.env, data.get('component').name)
filter = Transformer('//form[@id="modcomp"]/fieldset'
'/div[@class="field"][2]')
filter = filter.after(tag.div("Default CC:",
tag.br(),
tag.input(type='text',
name='defaultcc',
value=cc.cc),
class_='field')) \
.before(tag.input(type='hidden',
name='old_name',
value=cc.name))
return stream | filter
else:
filter = Transformer('//form[@id="addcomponent"]'
'/fieldset/div[@class="buttons"]')
stream |= filter.before(tag.div("Default CC:",
tag.br(),
tag.input(type='text',
name='defaultcc'),
class_='field'))
default_ccs = DefaultCC.select(self.env)
stream |= Transformer('//table[@id="complist"]/thead/tr') \
.append(tag.th('Default CC'))
for i, comp in enumerate(data.get('components')):
if comp.name in default_ccs:
default_cc = default_ccs[comp.name]
else:
default_cc = ''
filter = Transformer('//table[@id="complist"]'
'/tbody/tr[%d]' % (i + 1))
stream |= filter.append(tag.td(default_cc,
class_='defaultcc'))
return stream
return stream
示例5: filter_stream
# 需要导入模块: from genshi.filters import Transformer [as 别名]
# 或者: from genshi.filters.Transformer import before [as 别名]
def filter_stream(self, req, method, template, stream, data):
if not (template == 'browser.html' and data.get('dir')):
# Only interested if browsing directories
return stream
repos = data.get('repos') or self.env.get_repository()
rev = req.args.get('rev', None)
for entry in data['dir']['entries']:
try:
if not entry.isdir and entry.name.lower().startswith('readme'):
# Render any file starting with 'readme'
node = repos.get_node(entry.path, rev)
output = self._render_file(req, data['context'], repos,
node, rev=rev)
if output:
if isinstance(output['rendered'], Stream):
# strips the <div class="code" /> surrounding tag
content = output['rendered'].select('*')
else:
content = output['rendered']
insert_where = Transformer(
"//div[@id='content']/div[@id='help']")
insert_what = tag.div(
tag.h1(entry.name,
tag.a(Markup(' ¶'),
class_="anchor",
href='#'+entry.name,
title='Link to file'),
id_=entry.name
),
tag.div(
content,
class_="searchable",
style="background:#FBFBFB;border:2px solid #EEE;padding:0 1em;",
title=entry.name),
class_="readme",
style="padding-top:1em;"
)
stream = stream | insert_where.before(insert_what)
except Exception, e:
# Just log and ignore any kind of error (permissions and more)
self.log.debug(to_unicode(e))
示例6: filter_stream
# 需要导入模块: from genshi.filters import Transformer [as 别名]
# 或者: from genshi.filters.Transformer import before [as 别名]
#.........这里部分代码省略.........
if field_objects:
# list of field objects
stream = stream | Transformer(
'//table[@class="listing"]/thead/tr').append(
tag.th('CC'))
if field_name == 'component':
transformer = Transformer('//table[@id="complist"]/tbody')
default_comp = self.config.get(
'ticket', 'default_component')
for idx, field_object in enumerate(field_objects):
# Milestone object can be a tuple :/
try:
field_object_name = field_object.name
except AttributeError:
field_object_name = field_object[0].name
if field_object_name in default_ccs:
default_cc = default_ccs[field_object_name]
else:
default_cc = ''
# Annoyingly, we can't just append to the row if the
# collection is components, it appears to blat it for
# rendering later so you end up with no rows
# This may be due to the collection being a generator,
# but then again, who knows?
if field_name == 'component':
if default_comp == field_object_name:
default_tag = tag.input(
type='radio', name='default',
value=field_object_name, checked='checked')
else:
default_tag = tag.input(
type='radio', name='default',
value=field_object_name)
transformer = transformer.append(
tag.tr(
tag.td(
tag.input(type='checkbox', name='sel',
value=field_object_name),
class_='sel'),
tag.td(
tag.a(field_object_name,
href=req.href.admin(
'ticket', 'components') + '/' + \
field_object_name),
class_='name'),
tag.td(field_object.owner, class_='owner'),
tag.td(default_tag, class_='default'),
tag.td(default_cc, class_='defaultcc')
)
)
else:
stream = stream | Transformer(
'//table[@class="listing"]/tbody/tr[%s]' % (idx+1,)
).append(tag.td(default_cc, class_='defaultcc'))
if field_name == 'component':
return stream | transformer
else:
# edit field object
if field_name in self._non_abstract_enums:
field_object = data.get(field_name)
else:
field_object = data.get('enum')
if field_object:
# Milestone object can be a tuple :/
try:
field_object_name = field_object.name
except AttributeError:
field_object_name = field_object[0]
if field_object_name in default_ccs:
default_cc = default_ccs[field_object_name]
else:
default_cc = ''
transformer = Transformer(
'//form[@class="mod"]/fieldset/div[@class="buttons"]')
transformer = transformer.before(
tag.div(tag.label("Default CC:"), tag.br(),
tag.input(type="text", name="defaultcc",
value=default_cc),
class_="field")
).before(tag.input(type='hidden', name='old_name',
value=field_object_name))
return stream | transformer
return stream
示例7: filter_stream
# 需要导入模块: from genshi.filters import Transformer [as 别名]
# 或者: from genshi.filters.Transformer import before [as 别名]
def filter_stream(self, req, method, filename, stream, data):
if filename == "timeline.html":
# Insert the new field for entering user names
filter = Transformer('//form[@id="prefs"]/fieldset')
return stream | filter.before(self._user_field_input(req))
return stream
示例8: filter_stream
# 需要导入模块: from genshi.filters import Transformer [as 别名]
# 或者: from genshi.filters.Transformer import before [as 别名]
def filter_stream(self, req, method, filename, stream, data):
if filename == 'timeline.html':
# Insert the new field for entering user names
filter = Transformer('//form[@id="prefs"]/fieldset')
return stream | filter.before(tag.br()) | filter.before(tag.label("Filter Components (none for all): ")) | filter.before(tag.br()) | filter.before(self._components_field_input(req))
return stream
示例9: filter_stream
# 需要导入模块: from genshi.filters import Transformer [as 别名]
# 或者: from genshi.filters.Transformer import before [as 别名]
def filter_stream(self, req, method, filename, stream, data):
if re.match(r'^/(changeset|browser|attachment).*', req.path_info):
filter = Transformer('//h1')
stream |= filter.before(self._subscription_button(req.path_info))
return stream