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


Python Chrome.select方法代码示例

本文整理汇总了Python中trac.web.chrome.Chrome.select方法的典型用法代码示例。如果您正苦于以下问题:Python Chrome.select方法的具体用法?Python Chrome.select怎么用?Python Chrome.select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在trac.web.chrome.Chrome的用法示例。


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

示例1: _generate_form

# 需要导入模块: from trac.web.chrome import Chrome [as 别名]
# 或者: from trac.web.chrome.Chrome import select [as 别名]
    def _generate_form(self, req, data):
        userQueryData = dict(data)

        userQueryData['user_queries']   =[]

        userQueryData['empty_url']      = req.href.report()

        self.log.debug("Generating UserQueries navigation selector")

        # not really sure which is the best/definitive way yet:
        if userQueryData['report']:
            # SQL queries
            userQueryData['current_report_id'] = userQueryData['report']['id']
        elif userQueryData.has_key('report_resource'):
            # Custom queries in 0.11?
            userQueryData['current_report_id'] = int(userQueryData['report_resource'].id)
        elif userQueryData.has_key('context') and userQueryData['context'].req.args.has_key('report'):
            # Custom queries in 0.12?            
            userQueryData['current_report_id'] = int(userQueryData['context'].req.args['report'])
        else:
            # User visiting /report
            userQueryData['current_report_id'] = -1

        self.log.debug("User is visiting report %d", userQueryData['current_report_id'])

        db = self.env.get_db_cnx()
        cursor = db.cursor()
        cursor.execute("SELECT id AS report, title FROM report ORDER BY report")
        userQueryData['project_queries'] = [{'url': req.href.report(id),
                                             'id': id, 'name': title}
                                            for id, title in cursor]

        stream = Chrome(self.env).render_template(req, 'userqueries.html',
              userQueryData, fragment=True)
        return stream.select('//form')
开发者ID:CGI-define-and-primeportal,项目名称:trac-plugin-userqueries,代码行数:37,代码来源:web_ui.py

示例2: test_no_reports

# 需要导入模块: from trac.web.chrome import Chrome [as 别名]
# 或者: from trac.web.chrome.Chrome import select [as 别名]
    def test_no_reports(self):
        req = MockRequest()
        config = Mock(name='trunk', min_rev_time=lambda env: 0,
                      max_rev_time=lambda env: 1000, path='tmp/')
        build = Build(self.env, config='trunk', platform=1, rev=123,
                      rev_time=42)
        build.insert()
        step = BuildStep(self.env, build=build.id, name='foo',
                         status=BuildStep.SUCCESS)
        step.insert()

        summarizer = PyLintSummarizer(self.env)
        template, data = summarizer.render_summary(req, config, build, step,
                                                   'lint')
        self.assertEqual('bitten_summary_lint.html', template)
        self.assertEqual([], data['data'])
        self.assertEqual({'category': {'convention': 0, 'refactor': 0,
                                       'warning': 0, 'error': 0},
                          'files': 0, 'lines': 0, 'type': {}}, data['totals'])

        stream = Chrome(self.env).render_template(req, template,
                                                  {'data': data}, 'text/html',
                                                  fragment=True)
        stream = Stream(list(stream))
        for i, category in enumerate(("Convention", "Refactor", "Warning",
                                      "Error", "Totals")):
            text = stream.select('//tbody[@class="totals"]//td[%d]/text()'
                                 % (i + 1)).render()
            self.assertEqual('0', text, "Expected total for %r to have "
                             "value '0' but got %r" % (category, text))
开发者ID:hefloryd,项目名称:bitten,代码行数:32,代码来源:lint.py

示例3: filter_stream

# 需要导入模块: from trac.web.chrome import Chrome [as 别名]
# 或者: from trac.web.chrome.Chrome import select [as 别名]
    def filter_stream(self, req, method, filename, stream, data):
        action = req.args.get('action', '')
        
        if filename == 'browser.html' and action == 'edit':
            req.perm.require('REPOSITORY_MODIFY')
            # NB TracBrowserOps already inserts javascript and css we need
            # So only add css/javascript needed solely by the editor
            
            if data['file'] and data['file']['preview']['rendered']:
                max_edit_size = self.max_edit_size
                data['max_edit_size'] = max_edit_size
                
                # Discard rendered table, replace with textarea of file contents
                # This means reading the file from the repository again
                # N.B. If a file is rendered as something other than a table
                # e.g. due to PreCodeBrowserPlugin this code won't trigger
                
                # Retrieve the same node that BrowserModule.process_request() 
                # used to render the preview.
                # At this point reponame has been removed from data['path']
                # and repos has already been determined
                repos = data['repos']
                path = data['path']
                rev = data['rev']
                node = repos.get_node(path, rev)
                
                # If node is too large then don't allow editing, abort
                if max_edit_size > 0 and node.content_length > max_edit_size:
                    return stream
                
                # Open the node and read it
                node_file = node.get_content() 
                node_data = node_file.read()

                # Discover the mime type and character encoding of the node
                # Try in order
                #  - svn:mime-type property
                #  - detect from file name and content (BOM)
                #  - use configured default for Trac
                mime_view = Mimeview(self.env)
                mime_type = node.content_type \
                            or mime_view.get_mimetype(node.name, node_data) \
                            or 'text/plain'
                encoding = mime_view.get_charset(node_data, mime_type)
                
                # Populate template data
                content = mime_view.to_unicode(node_data, mime_type, encoding)
                data['file_content'] = content               
                data['file_encoding'] = encoding
                
                # Replace the already rendered preview with a form and textarea
                bsops_stream = Chrome(self.env).render_template(req,
                        'file_edit.html', data, fragment=True)
                transf = Transformer('//div[@id="preview"]'
                                     '/table[@class="code"]')
                stream |=  transf.replace(
                        bsops_stream.select('//div[@id="bsop_edit"]'))
        return stream
开发者ID:lkraav,项目名称:trachacks,代码行数:60,代码来源:web_ui.py

示例4: _generate_query_form

# 需要导入模块: from trac.web.chrome import Chrome [as 别名]
# 或者: from trac.web.chrome.Chrome import select [as 别名]
 def _generate_query_form(self, req, data):
     batchFormData = dict(data)
     batchFormData['query_href']= req.session['query_href'] \
                                  or req.href.query()
     
     add_script(req, 'batchmod/js/query_batchmod.js')
     add_stylesheet(req, 'batchmod/css/batchmod.css')
     stream = Chrome(self.env).render_template(req, 'query_batchmod.html',
           batchFormData, fragment=True)
     return stream.select('//form[@id="batchmod_form"]')
开发者ID:lkraav,项目名称:trachacks,代码行数:12,代码来源:query_batchmod.py

示例5: _generate_form

# 需要导入模块: from trac.web.chrome import Chrome [as 别名]
# 或者: from trac.web.chrome.Chrome import select [as 别名]
    def _generate_form(self, req, data):
        batchFormData = dict(data)
        batchFormData["query_href"] = req.session["query_href"] or req.href.query()

        ticketSystem = TicketSystem(self.env)
        fields = []
        for field in ticketSystem.get_ticket_fields():
            if field["name"] not in ("summary", "reporter", "description"):
                fields.append(field)
            if field["name"] == "owner" and hasattr(ticketSystem, "eventually_restrict_owner"):
                ticketSystem.eventually_restrict_owner(field)
        fields.sort(key=lambda f: f["name"])
        batchFormData["fields"] = fields

        add_script(req, "batchmod/js/batchmod.js")
        add_stylesheet(req, "batchmod/css/batchmod.css")
        stream = Chrome(self.env).render_template(req, "batchmod.html", batchFormData, fragment=True)
        return stream.select('//form[@id="batchmod_form"]')
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:20,代码来源:web_ui.py

示例6: filter_stream

# 需要导入模块: from trac.web.chrome import Chrome [as 别名]
# 或者: from trac.web.chrome.Chrome import select [as 别名]
    def filter_stream(self, req, method, filename, stream, formdata):
        # Don't check for req.path_info == '/query'. This will cause an
        # infinite loop. I think it is matching the actual QueryModule
        # component then.
        if filename == "query.html":
            self.log.debug("WhiteboardPlugin: rendering template")
            add_script(req, "whiteboard/js/jquery.equalheights.js")
            add_script(req, "whiteboard/js/jquery-ui.js")
            add_script(req, "whiteboard/js/whiteboard.js")
            add_stylesheet(req, "whiteboard/css/whiteboard.css")
            add_ctxtnav(req, "Whiteboard", "/#whiteboard")

            formdata["query_href"] = req.session["query_href"] or req.href.query()

            whiteboard_stream = Chrome(self.env).render_template(req, "whiteboard.html", formdata, fragment=True)
            return stream | Transformer('//h2[@class="report-result"]..').before(
                whiteboard_stream.select('//form[@id="whiteboard_form"]')
            )
        return stream
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:21,代码来源:web_ui.py

示例7: _generate_form

# 需要导入模块: from trac.web.chrome import Chrome [as 别名]
# 或者: from trac.web.chrome.Chrome import select [as 别名]
    def _generate_form(self, req, data):
        batchFormData = dict(data)
        batchFormData['query_href']= req.session['query_href'] \
                                     or req.href.query()
        batchFormData['notify_enabled'] = self.config.getbool('notification', 
                                                        'smtp_enabled', False)
        
        ticketSystem = TicketSystem(self.env)
        fields = []
        for field in ticketSystem.get_ticket_fields():
            if field['name'] not in ('summary', 'reporter', 'description'):
                fields.append(field)
            if field['name'] == 'owner' \
                and hasattr(ticketSystem, 'eventually_restrict_owner'):
                ticketSystem.eventually_restrict_owner(field)
        fields.sort(key=lambda f: f['name'])
        batchFormData['fields']=fields

        add_script(req, 'batchmod/js/batchmod.js')
        add_stylesheet(req, 'batchmod/css/batchmod.css')
        stream = Chrome(self.env).render_template(req, 'batchmod.html',
              batchFormData, fragment=True)
        return stream.select('//form[@id="batchmod_form"]')
开发者ID:lkraav,项目名称:trachacks,代码行数:25,代码来源:web_ui.py

示例8: _render_query_form_filters

# 需要导入模块: from trac.web.chrome import Chrome [as 别名]
# 或者: from trac.web.chrome.Chrome import select [as 别名]
 def _render_query_form_filters(self, req, data):
     if 'query_href' not in req.session:
         req.session['query_href'] = ''  # workaround crashing in batchmod
     fragment = Chrome(self.env).render_template(req, 'query.html', data,
                                                 None, fragment=True)
     return fragment.select('//fieldset[@id="filters"]')
开发者ID:KKBOX,项目名称:trac-ticket-calendar-plugin,代码行数:8,代码来源:web_ui.py

示例9: _generate_button

# 需要导入模块: from trac.web.chrome import Chrome [as 别名]
# 或者: from trac.web.chrome.Chrome import select [as 别名]
    def _generate_button(self, req, data):
        userQueryData = dict(data)

        stream = Chrome(self.env).render_template(req, 'userqueries_button.html',
              userQueryData, fragment=True)
        return stream.select('//form')
开发者ID:CGI-define-and-primeportal,项目名称:trac-plugin-userqueries,代码行数:8,代码来源:web_ui.py

示例10: _render_html

# 需要导入模块: from trac.web.chrome import Chrome [as 别名]
# 或者: from trac.web.chrome.Chrome import select [as 别名]

#.........这里部分代码省略.........
                                   context, tabwidth,
                                   ignore_blank_lines=ignore_blank_lines,
                                   ignore_case=ignore_case,
                                   ignore_space_changes=ignore_space)
            else:
                return []

        if 'FILE_VIEW' in req.perm:
            diff_bytes = diff_files = 0
            if self.max_diff_bytes or self.max_diff_files:
                for old_node, new_node, kind, change in get_changes():
                    if change in Changeset.DIFF_CHANGES and kind == Node.FILE:
                        diff_files += 1
                        diff_bytes += _estimate_changes(old_node, new_node)
            show_diffs = (not self.max_diff_files or \
                          diff_files <= self.max_diff_files) and \
                         (not self.max_diff_bytes or \
                          diff_bytes <= self.max_diff_bytes or \
                          diff_files == 1)
        else:
            show_diffs = False

        # XHR is used for blame support: display the changeset view without
        # the navigation and with the changes concerning the annotated file
        annotated = False
        if xhr:
            show_diffs = False
            annotated = repos.normalize_path(req.args.get('annotate'))

        has_diffs = False
        filestats = self._prepare_filestats()
        changes = []
        files = []
        for old_node, new_node, kind, change in get_changes():
            props = []
            diffs = []
            show_entry = change != Changeset.EDIT
            show_diff = show_diffs or (new_node and new_node.path == annotated)

            if change in Changeset.DIFF_CHANGES and 'FILE_VIEW' in req.perm:
                assert old_node and new_node
                props = _prop_changes(old_node, new_node)
                if props:
                    show_entry = True
                if kind == Node.FILE and show_diff:
                    diffs = _content_changes(old_node, new_node)
                    if diffs != []:
                        if diffs:
                            has_diffs = True
                        # elif None (means: manually compare to (previous))
                        show_entry = True
            if show_entry or not show_diff:
                info = {'change': change,
                        'old': old_node and node_info(old_node, annotated),
                        'new': new_node and node_info(new_node, annotated),
                        'props': props,
                        'diffs': diffs}
                files.append(new_node and new_node.path or \
                             old_node and old_node.path or '')
                filestats[change] += 1
                if change in Changeset.DIFF_CHANGES:
                    if chgset:
                        href = req.href.changeset(new_node.rev, new_node.path)
                        title = _('Show the changeset %(id)s restricted to '
                                  '%(path)s', id=new_node.rev,
                                  path=new_node.path)
                    else:
                        href = req.href.changeset(
                            new_node.created_rev, new_node.created_path,
                            old=old_node.created_rev,
                            old_path=old_node.created_path)
                        title = _('Show the %(range)s differences restricted '
                                  'to %(path)s',
                                  range='r%s:%s' % (old_node.rev, new_node.rev),
                                  path=new_node.path)
                    info['href'] = href
                    info['title'] = old_node and title
                if change in Changeset.DIFF_CHANGES and not show_diff:
                    info['hide_diff'] = True
            else:
                info = None
            changes.append(info) # the sequence should be immutable

        data.update({'has_diffs': has_diffs, 'changes': changes, 'xhr': xhr,
                     'filestats': filestats, 'annotated': annotated,
                     'files': files, 
                     'location': self._get_parent_location(files),
                     'longcol': 'Revision', 'shortcol': 'r'})

        if xhr: # render and return the content only
            stream = Chrome(self.env).render_template(req, 'changeset.html',
                                                      data, fragment=True)
            content = stream.select('//div[@id="content"]')
            str_content = content.render('xhtml')
            req.send_header('Content-Length', len(str_content))
            req.end_headers()
            req.write(str_content)
            raise RequestDone

        return data
开发者ID:gdgkyoto,项目名称:kyoto-gtug,代码行数:104,代码来源:changeset.py

示例11: test_basic_report

# 需要导入模块: from trac.web.chrome import Chrome [as 别名]
# 或者: from trac.web.chrome.Chrome import select [as 别名]
    def test_basic_report(self):
        req = MockRequest()
        config = Mock(name='trunk', min_rev_time=lambda env: 0,
                      max_rev_time=lambda env: 1000, path='tmp/')
        build = Build(self.env, config='trunk', platform=1, rev=123,
                      rev_time=42)
        build.insert()
        step = BuildStep(self.env, build=build.id, name='foo',
                         status=BuildStep.SUCCESS)
        step.insert()
        report = Report(self.env, build=build.id, step='foo', category='lint')
        for line, category in enumerate(['convention', 'warning', 'error',
                                         'refactor', 'warning', 'error',
                                         'refactor', 'error', 'refactor',
                                         'refactor']):
            item = {'category': category, 'file': 'foo.py', 'type': 'unknown'}
            if line % 3 == 0:
                item['line'] = line
            if line % 2 == 0:
                item['msg'] = 'error'
            report.items.append(item)
        report.insert()
        summarizer = PyLintSummarizer(self.env)
        template, data = summarizer.render_summary(req, config, build, step,
                                                   'lint')
        self.assertEqual('bitten_summary_lint.html', template)
        self.assertEqual([{'category': {'warning': 2, 'error': 3,
                                        'refactor': 4, 'convention': 1},
                           'catnames': ['warning', 'error', 'refactor',
                                        'convention'],
                           'lines': 10, 'href': '/browser/tmp/foo.py',
                           'file': 'foo.py', 'type': {'unknown': 10},
                           'details': sorted([(i % 3 != 0 and '??' or i,
                                               'unknown',
                                               i % 2 != 0 and '-' or 'error')
                                              for i in range(10)])}],
                         data['data'])
        self.assertEqual({'category': {'convention': 1, 'refactor': 4,
                                       'warning': 2, 'error': 3},
                          'files': 1, 'lines': 10, 'type': {'unknown': 10}},
                         data['totals'])

        stream = Chrome(self.env).render_template(req, template,
                                                  {'data': data}, 'text/html',
                                                  fragment=True)
        stream = Stream(list(stream))
        file_text = stream.select('//tr[@class="file failed"]/th/a/text()').render()
        self.assertEqual("foo.py", file_text)
        for i, (category, cnt) in enumerate([
                ("Convention", 1), ("Refactor", 4),
                ("Warning", 2), ("Error", 3),
                ("Totals", 10)
                ]):
            text = stream.select('//tbody[@class="totals"]//td[%d]/text()'
                                 % (i + 1)).render().strip()
            self.assertEqual(str(cnt), text, "Expected total for %r to have "
                             "value '%d' but got %r" % (category, cnt, text))
            text_file = stream.select('//table/tbody[1]//td[%d]/text()'
                                 % (i + 1)).render().strip()
            self.assertEqual(str(cnt), text_file, "Expected category %r for "
                             "foo.py to have value '%d' but got %r" %
                             (category, cnt, text_file))
开发者ID:hefloryd,项目名称:bitten,代码行数:64,代码来源:lint.py

示例12: _generate_form

# 需要导入模块: from trac.web.chrome import Chrome [as 别名]
# 或者: from trac.web.chrome.Chrome import select [as 别名]
    def _generate_form(self, req, data):
        batchFormData = dict(data)

        stream = Chrome(self.env).render_template(req, 'querymod.html',
              batchFormData, fragment=True)
        return stream.select('.')
开发者ID:alvabai,项目名称:trac-multiproject,代码行数:8,代码来源:modquery.py


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