当前位置: 首页>>代码示例>>Python>>正文


Python filters.Transformer类代码示例

本文整理汇总了Python中genshi.filters.Transformer的典型用法代码示例。如果您正苦于以下问题:Python Transformer类的具体用法?Python Transformer怎么用?Python Transformer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Transformer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: generate

    def generate(self, *args, **kwargs):
        "creates the RelatorioStream."
        serializer = OOSerializer(self._zip_source)
        kwargs['__relatorio_make_href'] = ImageHref(serializer.outzip,
                                                    serializer.manifest,
                                                    kwargs)
        kwargs['__relatorio_make_dimension'] = ImageDimension(self.namespaces)
        kwargs['__relatorio_guess_type'] = guess_type

        counter = ColumnCounter()
        kwargs['__relatorio_reset_col_count'] = counter.reset
        kwargs['__relatorio_inc_col_count'] = counter.inc
        kwargs['__relatorio_store_col_count'] = counter.store

        cache = ExpressionCache()
        kwargs['__relatorio_store_cache'] = cache.store
        kwargs['__relatorio_get_cache'] = cache.get

        stream = super(Template, self).generate(*args, **kwargs)
        if self.has_col_loop:
            # Note that we can't simply add a "number-columns-repeated"
            # attribute and then fill it with the correct number of columns
            # because that wouldn't work if more than one column is repeated.
            transformation = DuplicateColumnHeaders(counter)
            col_filter = Transformer('//repeat[namespace-uri()="%s"]'
                                     % RELATORIO_URI)
            col_filter = col_filter.apply(transformation)
            stream = Stream(list(stream), self.serializer) | col_filter
        return RelatorioStream(stream, serializer)
开发者ID:bitsworking,项目名称:relatorio,代码行数:29,代码来源:opendocument.py

示例2: filter_stream

    def filter_stream(self, req, method, filename, stream, data):
        """
        Reformat the ``branch`` field of a ticket to show the history of the
        linked branch.
        """
        if filename == 'ticket.html':
            ticket = data.get('ticket')
            if ticket and ticket.exists:
                branch = ticket['branch']
                if branch:
                    error = None
                    if not self._is_valid_branch_name(branch):
                        error = "not a valid branch name"
                    elif not self._is_existing_branch(branch):
                        error = "branch does not exist"
                    else:
                        try:
                            master = self._dereference_head(MASTER_BRANCH)
                            branch = self._dereference_head(branch)
                            common_ancestor = self._common_ancestor(master,branch)
                            if branch == common_ancestor:
                                # the trac log page does not work if the revisions are equal
                                error = "no commits on branch yet"
                            else:
                                filter = Transformer('//td[@headers="h_branch"]/text()')
                                stream |= filter.wrap(tag.a(href=req.href.log(revs="%s-%s"%(common_ancestor,branch))))
                        except GitError:
                            error = "failed to determine common ancestor with %s branch"%MASTER_BRANCH

                    if error:
                        filter = Transformer('//td[@headers="h_branch"]')
                        stream |= filter.attr("title",error)

        return stream
开发者ID:saraedum,项目名称:sage_trac,代码行数:34,代码来源:ticket_branch.py

示例3: filter_stream

    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
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:33,代码来源:web_ui.py

示例4: filter_stream

 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
开发者ID:pkdevbox,项目名称:trac,代码行数:7,代码来源:clone.py

示例5: filter_stream

 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
开发者ID:boldprogressives,项目名称:trac-NewTicketLikeThisPlugin,代码行数:8,代码来源:core.py

示例6: filter_stream

 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
开发者ID:Automattic,项目名称:trac-code-comments-plugin,代码行数:8,代码来源:subscription.py

示例7: filter_stream

    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
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:9,代码来源:ticket_clone.py

示例8: filter_stream

 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
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:10,代码来源:ajaxquery.py

示例9: filter_stream

    def filter_stream(self, req, method, filename, stream, data):
        """
        Wrap the banner and mainnav in a single banner_wrapper div
        """
        buffer = StreamBuffer()
        filter = Transformer("//div[@id='banner']")
        stream |= filter.wrap(tag.div(id="banner_wrapper")).end(
            ).select("//div[@id='mainnav']").cut(buffer, accumulate=True).end().buffer(
            ).select("//div[@id='banner_wrapper']").append(tag.hr()).append(buffer).end()

        return stream
开发者ID:pombredanne,项目名称:trac-LighterTheme,代码行数:11,代码来源:__init__.py

示例10: filter_stream

 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
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:13,代码来源:web_ui.py

示例11: filter_stream

 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
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:16,代码来源:ajaxcomments.py

示例12: filter_stream

    def filter_stream(self, req, method, filename, stream, data):
        if filename == 'ticket.html' and req.authname != 'anonymous':
            ticket = data.get('ticket')
            if req.perm.has_permission('TICKET_ADMIN'):
    	        self.log.debug("TicketChangePlugin adding 'Change' links for ticket %s" % ticket.id)
                buffer = StreamBuffer()
                
                def insert_change_link():
                    cnum = list(buffer)[0][1][1][0][1]
                    return tag(" ", tag.a("Change", href=("../ticketchangecomment/%s?cnum=%s" % (ticket.id, cnum))))

                filter = Transformer("//div[@class='change']/div[@class='inlinebuttons']/input[@name='replyto']/@value")
                return stream | filter.copy(buffer).end() \
                              .select("//div[@class='change']/div[@class='inlinebuttons']/input[@value='Reply']") \
                              .after(insert_change_link)
        return stream
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:16,代码来源:web_ui.py

示例13: filter_stream

    def filter_stream(self, req, method, filename, stream, data):
        if 'TICKET_ADMIN' in req.perm:
            if req.path_info == '/admin/ticket/components' or req.path_info == '/admin/ticket/components/':
                components = data.get('components')
                # 'components' will be None if component with specified name already exists.
                if not components:
                    return stream
                
                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 components:
                    if default_comp == comp.name:
                        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 req.path_info.startswith('/admin/ticket/components/') and 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
开发者ID:gaod,项目名称:trac-DefaultCcPlugin,代码行数:44,代码来源:admin.py

示例14: filter_stream

    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
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:19,代码来源:roadmap.py

示例15: _show_branches_tags

 def _show_branches_tags(self, req, info, changes):
     filters = []
     for idx, item in enumerate(info):
         change = changes[item['rev']]
         branch_filter = Transformer('//table/tbody/tr[%d]/td[@class="summary"]' % (idx+1))
         
         for name, head in change.get_branches():
             #if branch not in ('default', 'master'):
             
             span = tag.span(name, class_="branch" + (" head" if head else ''),
                           title="Branch head" if head else 'Branch')
             filters.append(branch_filter.append(span))
             
             
         for tagname in change.get_tag_contains():
             span = tag.span(tagname, class_="tag", title="Tag")
             filters.append(branch_filter.append(span))
         
     return filters
开发者ID:wadahiro,项目名称:trac-revision-graph-plugin,代码行数:19,代码来源:web_ui.py


注:本文中的genshi.filters.Transformer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。