本文整理汇总了Python中genshi.filters.Transformer.after方法的典型用法代码示例。如果您正苦于以下问题:Python Transformer.after方法的具体用法?Python Transformer.after怎么用?Python Transformer.after使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类genshi.filters.Transformer
的用法示例。
在下文中一共展示了Transformer.after方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: filter_stream
# 需要导入模块: from genshi.filters import Transformer [as 别名]
# 或者: from genshi.filters.Transformer import after [as 别名]
def filter_stream(self, req, method, filename, stream, data):
if filename == 'ticket.html':
ticket = data.get('ticket')
if ticket and ticket.exists and \
req.session.get(self.session_field, 'True') == 'True':
filter_ = Transformer(
'//script[contains(@src, "jquery.js")]')
return stream | filter_.after(
tag.script(
type="text/javascript",
src=self.env.href('chrome', 'ac', 'js', 'jquery.form.js'))) \
| filter_.after(
tag.script(
type="text/javascript",
src=self.env.href('chrome', 'ac', 'js', 'comments.js')))
return stream
示例2: filter_stream
# 需要导入模块: from genshi.filters import Transformer [as 别名]
# 或者: from genshi.filters.Transformer import after [as 别名]
def filter_stream(self, req, method, filename, stream, data):
if filename == "ticket.html":
ticket = data.get("ticket")
if ticket and ticket.exists and "TICKET_ADMIN" in req.perm(ticket.resource):
filter = Transformer('//h3[@id="comment:description"]')
stream |= filter.after(self._clone_form(req, ticket, data))
return stream
示例3: filter_stream
# 需要导入模块: from genshi.filters import Transformer [as 别名]
# 或者: from genshi.filters.Transformer import after [as 别名]
def filter_stream(self, req, method, filename, stream, data):
# Add delete buttons to the ticket form
ticket = data.get("ticket")
if filename == "ticket.html" and "TICKET_ADMIN" in req.perm(ticket.resource):
# Add Delete button to ticket description
if data["ticket"].values["description"]:
# Reply button and associated elements are present
filter = Transformer("//div[@class='description']//div[@class='inlinebuttons']")
stream |= filter.append(
tag.input(type="submit", name="delete", title="Delete this ticket", value="Delete")
)
else:
# Reply button and associated elements not present
filter = Transformer("//div[@class='description']/h3")
stream |= filter.after(
tag.form(
tag.div(
tag.input(type="submit", name="delete", title="Delete this ticket", value="Delete"),
class_="inlinebuttons",
),
name="addreply",
method="get",
action="#comment",
)
)
# Add Delete buttons to ticket comments
stream |= Transformer("//div[@id='changelog']//div[@class='inlinebuttons']").append(
tag.input(type="submit", name="delete", title="Delete this comment", value="Delete")
)
return stream
示例4: filter_stream
# 需要导入模块: from genshi.filters import Transformer [as 别名]
# 或者: from genshi.filters.Transformer import after [as 别名]
def filter_stream(self, req, method, filename, stream, data):
if filename == 'ticket.html':
ticket = data.get('ticket')
if ticket and ticket.exists and \
self.ticket_clone_permission in req.perm(ticket.resource):
filter = Transformer('//h3[@id="comment:description"]')
stream |= filter.after(self._clone_form(req, ticket, data))
return stream
示例5: filter_stream
# 需要导入模块: from genshi.filters import Transformer [as 别名]
# 或者: from genshi.filters.Transformer import after [as 别名]
def filter_stream(self, req, method, filename, stream, data):
if filename == 'ticket.html':
ticket = data.get('ticket')
if ticket and ticket.exists and \
'TICKET_CREATE' in req.perm(ticket.resource):
# filter = Transformer('//h3[@id="comment:description"]')
filter = Transformer( self.config.get('trac', 'clone_xpath') )
return stream | filter.after(self._clone_form(req, ticket, data))
return stream
示例6: filter_stream
# 需要导入模块: from genshi.filters import Transformer [as 别名]
# 或者: from genshi.filters.Transformer import after [as 别名]
def filter_stream(self, req, method, filename, stream, data):
if filename == 'query.html':
filter_script = Transformer('//script[contains(@src, "jquery.js")]')
filter_query = Transformer('table[@class="listing tickets"]/.')
return stream | filter_script.after(
tag.script(
type="text/javascript",
src=self.env.href('chrome', 'aq', 'js', 'query.js'))) \
| filter_query.prepend('<!-- Hello -->')
return stream
示例7: filter_stream
# 需要导入模块: from genshi.filters import Transformer [as 别名]
# 或者: from genshi.filters.Transformer import after [as 别名]
def filter_stream(self, req, method, filename, stream, data):
if filename == 'ticket.html':
ticket = data.get('ticket')
if ticket and ticket.exists:
context = Context.from_request(req, ticket.resource)
self.changesets = TicketChangesetsFormatter(self.env, context,
ticket.id)
exists = self.changesets.exists()
if exists or not self.hide_when_none:
filter = Transformer('//div[@id="attachments"]')
return stream | filter.after(self._render(req, ticket,
exists))
return stream
示例8: filter_stream
# 需要导入模块: from genshi.filters import Transformer [as 别名]
# 或者: from genshi.filters.Transformer import after [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
示例9: filter_stream
# 需要导入模块: from genshi.filters import Transformer [as 别名]
# 或者: from genshi.filters.Transformer import after [as 别名]
def filter_stream(self, req, method, filename, stream, data):
"""Adds button to ticket page."""
if filename != 'ticket.html':
return stream
ticket = data.get('ticket')
permission = self.config.get(CONFIG_SECTION, 'permission')
if not ticket or not ticket.exists or permission not in req.perm(ticket.resource):
return stream
url = self.config.get(CONFIG_SECTION, 'kanban_base_url')
service = LeanKitService(url, self.env)
team_field = self.config.get(CONFIG_SECTION, 'trac_team_field')
board = service.get_board(ticket[team_field])
if not board:
return stream
if ticket['status'] == 'closed':
return stream
html = Transformer('//div[@class="description"]')
return stream | html.after(self._kanban_form(board, ticket))
示例10: filter_stream
# 需要导入模块: from genshi.filters import Transformer [as 别名]
# 或者: from genshi.filters.Transformer import after [as 别名]
def filter_stream(self, req, method, filename, stream, data):
"""Return a filtered Genshi event stream, or the original unfiltered
stream if no match.
`req` is the current request object, `method` is the Genshi render
method (xml, xhtml or text), `filename` is the filename of the template
to be rendered, `stream` is the event stream and `data` is the data for
the current template.
See the Genshi documentation for more information.
"""
if filename != 'ticket.html':
return stream
ticket = data['ticket']
for provider in self.providers: # TODO : sorting
if provider.enabled(req, ticket):
add_stylesheet(req, 'common/css/ticket-sidebar.css')
filter = Transformer('//div[@id="content"]')
stream |= filter.after(tag.div(provider.content(req, ticket),
**{'class': "sidebar" }))
return stream
示例11: filter_stream
# 需要导入模块: from genshi.filters import Transformer [as 别名]
# 或者: from genshi.filters.Transformer import after [as 别名]
def filter_stream(self, req, method, filename, stream, data):
"""Return a filtered Genshi event stream, or the original unfiltered
stream if no match.
"""
if filename == "ticket.html" and \
('TICKET_REMINDER_VIEW' in req.perm or
'TICKET_REMINDER_MODIFY' in req.perm or
'TICKET_ADMIN' in req.perm):
tags = self._reminder_tags(req, data)
if tags:
ticket_resource = data['ticket'].resource
context = Context.from_request(req, ticket_resource)
attachments_data = AttachmentModule(self.env).attachment_data(context)
add_stylesheet(req, 'ticketreminder/css/ticketreminder.css')
# Will attachments section be displayed?
attachments_or_ticket = Transformer('//div[@id="attachments"]') if attachments_data['can_create'] or attachments_data['attachments'] else Transformer('//div[@id="ticket"]')
trac_nav = Transformer('//form[@id="propertyform"]/div[@class="trac-nav"]')
return stream | attachments_or_ticket.after(tags) | trac_nav.append(self._reminder_trac_nav(req, data))
return stream
示例12: _customize_View
# 需要导入模块: from genshi.filters import Transformer [as 别名]
# 或者: from genshi.filters.Transformer import after [as 别名]
def _customize_View(self, stream):
filter = Transformer('.//div [@id="banner"]')
stream = stream | filter.wrap(self.css_banner_top2)
buffer = StreamBuffer()
stream = stream | Transformer('.//div [@id="banner"]').copy(buffer).end().select('.//div [@id="top2"]').after(
tag.div(id_="top1")(buffer)
)
filter = Transformer('.//div [@id="mainnav"]')
stream = stream | filter.wrap(self.css_banner_top4)
buffer = StreamBuffer()
stream = stream | Transformer('.//div [@id="mainnav"]').copy(buffer).end().select('.//div [@id="top4"]').after(
tag.div(id_="top3")(buffer)
)
filter = Transformer('.//div [@id="top3"]')
stream = stream | filter.after(tag.div(id_="right")(tag.p()))
filter = Transformer('.//div [@id="right"]')
stream = stream | filter.append(tag.div(class_="wiki-toc")(tag.h4(_("Table of Contents"))))
# just for the menu / TOC
filter = Transformer('.//div [@class="wiki-toc"]')
if self.anchors and self.keylist:
for key in self.keylist:
stream = stream | filter.append(
tag.a(key, href="#" + self.anchors.get(key), onclick="scrollup();") + tag.br()
)
filter = Transformer('.//div [@id="main"]')
stream = stream | filter.wrap(self.css_left)
return stream
示例13: filter_stream
# 需要导入模块: from genshi.filters import Transformer [as 别名]
# 或者: from genshi.filters.Transformer import after [as 别名]
def filter_stream(self, req, method, filename, stream, data):
if filename == 'changeset.html':
changeset = data.get('changeset')
filter = Transformer('//dd[@class="message searchable"]')
return stream | filter.after(self._review_attrs(req,changeset))
return stream
示例14: filter_stream
# 需要导入模块: from genshi.filters import Transformer [as 别名]
# 或者: from genshi.filters.Transformer import after [as 别名]
#.........这里部分代码省略.........
# As follows:
# - If ticket has no child tickets and child tickets are NOT allowed then skip.
# - If ticket has child tickets and child tickets are NOT allowed (ie. rules changed or ticket type changed after children were assigned),
# print list of tickets but do not allow any tickets to be created.
# - If child tickets are allowed then print list of child tickets or 'No Child Tickets' if non are currently assigned.
#
if ticket and ticket.exists:
# The additional section on the ticket is built up of (potentially) three parts: header, ticket table, buttons. These
# are all 'wrapped up' in a 'div' with the 'attachments' id (we'll just pinch this to make look and feel consistent with any
# future changes!)
filter = Transformer('//div[@id="ticket"]')
snippet = tag.div()
# Are there any child tickets to display?
childtickets = [ Ticket(self.env,n) for n in self.childtickets.get(ticket.id,[]) ]
# (tempish) fix for #8612 : force sorting by ticket id
childtickets = sorted(childtickets, key=lambda t: t.id)
# Are child tickets allowed?
childtickets_allowed = self.config.getbool('childtickets', 'parent.%s.allow_child_tickets' % ticket['type'])
# If there are no childtickets and the ticket should not have any child tickets, we can simply drop out here.
if not childtickets_allowed and not childtickets:
return stream
# Our 'main' display consists of two divs.
buttondiv = tag.div()
tablediv = tag.div()
# Test if the ticket has children: If so, then list in pretty table.
if childtickets:
# trac.ini : Which columns to display in child ticket listing?
columns = self.config.getlist('childtickets', 'parent.%s.table_headers' % ticket['type'], default=['summary','owner'])
tablediv = tag.div(
tag.table(
tag.thead(
tag.tr(
tag.th("Ticket",class_="id"),
[ tag.th(s.title(),class_=s) for s in columns ])
),
tag.tbody([ self._table_row(req,tkt,columns) for tkt in childtickets ]),
class_="listing tickets",
),
tag.br(),
)
# trac.ini : child tickets are allowed - Set up 'create new ticket' buttons.
if childtickets_allowed:
# Can user create a new ticket? If not, just display title (ie. no 'create' button).
if 'TICKET_CREATE' in req.perm(ticket.resource):
# Always pass these fields
default_child_fields = (
tag.input(type="hidden", name="parent", value='#'+str(ticket.id)),
)
#Pass extra fields defined in inherit parameter of parent
inherited_child_fields = [
tag.input(type="hidden",name="%s"%field,value=ticket[field]) for field in self.config.getlist('childtickets','parent.%s.inherit' % ticket['type'])
]
# If child types are restricted then create a set of buttons for the allowed types (This will override 'default_child_type).
restrict_child_types = self.config.getlist('childtickets','parent.%s.restrict_child_type' % ticket['type'],default=[])
if not restrict_child_types:
# trac.ini : Default 'type' of child tickets?
default_child_type = self.config.get('childtickets', 'parent.%s.default_child_type' % ticket['type'], default=self.config.get('ticket','default_type'))
# ... create a default submit button
if ticket['status'] == 'closed':
submit_button_fields = (
tag.input(type="submit",disabled="disabled",name="childticket",value="New Child Ticket",title="Create a child ticket"),
tag.input(type="hidden", name="type", value=default_child_type),
)
else:
submit_button_fields = (
tag.input(type="submit",name="childticket",value="New Child Ticket",title="Create a child ticket"),
tag.input(type="hidden",name="type",value=default_child_type),
)
else:
if ticket['status'] == 'closed':
submit_button_fields = [ tag.input(type="submit",disabled="disabled",name="type",value="%s" % ticket_type,title="Create a %s child ticket" % ticket_type) for ticket_type in restrict_child_types ]
else:
submit_button_fields = [ tag.input(type="submit",name="type",value="%s" % ticket_type,title="Create a %s child ticket" % ticket_type) for ticket_type in restrict_child_types ]
buttondiv = tag.form(
tag.div( default_child_fields, inherited_child_fields, submit_button_fields),
method="get", action=req.href.newticket(),
)
snippet.append(tag.h2("Child Tickets",class_="foldable"))
snippet.append(tag.div(tablediv, buttondiv, id="childtickets"))
return stream | filter.after(snippet)
return stream
示例15: filter_stream
# 需要导入模块: from genshi.filters import Transformer [as 别名]
# 或者: from genshi.filters.Transformer import after [as 别名]
def filter_stream(self, req, method, filename, stream, data):
# this is shamelessly stollen from MasterTickets
if data and filename in ["report_view.html", "query_results.html", "ticket.html", "query.html"]:
self._link_parent(req, filename, data)
# Tickets will be modified to show the child tickets as a list under the 'Description' section.
if filename == 'ticket.html':
# Add our own styles for the ticket lists.
add_stylesheet(req, 'ct/css/childtickets.css')
add_stylesheet(req, 'common/css/report.css')
add_stylesheet(req, 'common/css/roadmap.css')
add_script(req, 'ct/js/childtickets.js')
# Get the ticket info.
ticket = data.get('ticket')
# Modify ticket.html with sub-ticket table, create button, etc...
# As follows:
# - If ticket has no child tickets and child tickets are NOT allowed then skip.
# - If ticket has child tickets and child tickets are NOT allowed (ie. rules changed or ticket type changed after children were assigned),
# print list of tickets but do not allow any tickets to be created.
# - If child tickets are allowed then print list of child tickets or 'No Child Tickets' if non are currently assigned.
#
if ticket and ticket.exists:
# The additional section on the ticket is built up of (potentially) three parts: header, ticket table, buttons. These
# are all 'wrapped up' in a 'div' with the 'attachments' id (we'll just pinch this to make look and feel consistent with any
# future changes!)
filter = Transformer('//div[@id="ticket"]')
snippet = tag.div()
priorities = dict([(p.name, int(p.value)) for p in Priority.select(self.env)])
# Are there any child tickets to display?
childtickets = self._get_childtickets(ticket, priorities)
# Are child tickets allowed?
childtickets_allowed = self.config.getbool('childtickets', 'parent.%s.allow_child_tickets' % ticket['type'])
# If there are no childtickets and the ticket should not have any child tickets, we can simply drop out here.
if not childtickets_allowed and not childtickets:
return stream
# Our 'main' display consists of two divs.
buttondiv = tag.div()
tablediv = tag.div()
progresshtml = tag.div()
# Test if the ticket has children: If so, then list in pretty table.
if childtickets:
progresshtml = self._construct_progress(req, ticket)
tablediv = self._contruct_tickets_table(req, ticket, childtickets, priorities)
# trac.ini : child tickets are allowed - Set up 'create new ticket' buttons.
if childtickets_allowed and 'TICKET_CREATE' in req.perm(ticket.resource):
buttondiv = self._contruct_buttons(req, ticket)
snippet.append(tag.h2("Child Tickets",class_="foldable"))
snippet.append(tag.div(progresshtml, tablediv, buttondiv, id="childtickets"))
return stream | filter.after(snippet)
return stream