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


Python resource.get_resource_description函数代码示例

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


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

示例1: expand_macro

    def expand_macro(self, formatter, name, content):
        env = formatter.env
        req = formatter.req
        if not 'VOTE_VIEW' in req.perm:
            return
        # Simplify function calls.
        format_author = partial(Chrome(self.env).format_author, req)
        if not content:
            args = []
            compact = None
            kw = {}
            top = 5
        else:
            args, kw = parse_args(content)
            compact = 'compact' in args and True
            top = as_int(kw.get('top'), 5, min=0)

        if name == 'LastVoted':
            lst = tag.ul()
            for i in self.get_votes(req, top=top):
                resource = Resource(i[0], i[1])
                # Anotate who and when.
                voted = ('by %s at %s'
                         % (format_author(i[3]),
                            format_datetime(to_datetime(i[4]))))
                lst(tag.li(tag.a(
                    get_resource_description(env, resource, compact and
                                             'compact' or 'default'),
                    href=get_resource_url(env, resource, formatter.href),
                    title=(compact and '%+i %s' % (i[2], voted) or None)),
                    (not compact and Markup(' %s %s' % (tag.b('%+i' % i[2]),
                                                        voted)) or '')))
            return lst

        elif name == 'TopVoted':
            realm = kw.get('realm')
            lst = tag.ul()
            for i in self.get_top_voted(req, realm=realm, top=top):
                if 'up-only' in args and i[2] < 1:
                    break
                resource = Resource(i[0], i[1])
                lst(tag.li(tag.a(
                    get_resource_description(env, resource, compact and
                                             'compact' or 'default'),
                    href=get_resource_url(env, resource, formatter.href),
                    title=(compact and '%+i' % i[2] or None)),
                    (not compact and ' (%+i)' % i[2] or '')))
            return lst

        elif name == 'VoteList':
            lst = tag.ul()
            resource = resource_from_path(env, req.path_info)
            for i in self.get_votes(req, resource, top=top):
                vote = ('at %s' % format_datetime(to_datetime(i[4])))
                lst(tag.li(
                    compact and format_author(i[3]) or
                    Markup(u'%s by %s %s' % (tag.b('%+i' % i[2]),
                                             tag(format_author(i[3])), vote)),
                    title=(compact and '%+i %s' % (i[2], vote) or None)))
            return lst
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:60,代码来源:__init__.py

示例2: test_resource_repository

    def test_resource_repository(self):
        res = Resource('repository', 'testrepo')
        self.assertEqual('Repository testrepo',
                         get_resource_description(self.env, res))
        self.assertEqual('/trac.cgi/browser/testrepo',
                         get_resource_url(self.env, res, self.env.href))

        res = Resource('repository', '')  # default repository
        self.assertEqual('Default repository',
                         get_resource_description(self.env, res))
        self.assertEqual('/trac.cgi/browser',
                         get_resource_url(self.env, res, self.env.href))
开发者ID:exocad,项目名称:exotrac,代码行数:12,代码来源:api.py

示例3: test_resource_changeset

    def test_resource_changeset(self):
        res = Resource('changeset', '42')
        self.assertEqual('Changeset 42', get_resource_description(self.env, res))
        self.assertEqual('/trac.cgi/changeset/42',
                         get_resource_url(self.env, res, self.env.href))

        repo = Resource('repository', 'repo')
        res = Resource('changeset', '42', parent=repo)
        self.assertEqual('Changeset 42 in repo',
                         get_resource_description(self.env, res))
        self.assertEqual('/trac.cgi/changeset/42/repo',
                         get_resource_url(self.env, res, self.env.href))
开发者ID:exocad,项目名称:exotrac,代码行数:12,代码来源:api.py

示例4: _do_view

 def _do_view(self, env, req, form):
     data = {}
     form_id = form.resource.id
     data['page_title'] = get_resource_description(env, form.resource,
                                                   href=req.href)
     data['title'] = get_resource_shortname(env, form.resource)
     # prime list with current state
     subcontext, author, time = self.get_tracform_meta(form_id)[3:6]
     if not subcontext == '':
         data['subcontext'] = subcontext
     state = self.get_tracform_state(form_id)
     data['fields'] = self._render_fields(form_id, state)
     history = [{'author': author, 'time': time,
                 'old_state': state}]
     # add recorded old_state
     records = self.get_tracform_history(form_id)
     for author, time, old_state in records:
         history.append({'author': author, 'time': time,
                         'old_state': old_state})
     data['history'] = parse_history(history)
     # show reset button in case of existing data and proper permission
     data['allow_reset'] = req.perm(form.resource) \
                           .has_permission('FORM_RESET') and form.has_data
     add_stylesheet(req, 'tracforms/tracforms.css')
     return 'form.html', data, None
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:25,代码来源:web_ui.py

示例5: get_resource_description

 def get_resource_description(self, resource, format="default", context=None, **kwargs):
     page = WikiPage(self.env, resource.id)
     if page.exists:
         return get_resource_description(self.env, page.resource, format, **kwargs)
     rid = to_unicode(resource.id)
     if format in ("compact", "default"):
         return rid
     else:
         return u"tag:%s" % rid
开发者ID:okamototk,项目名称:kanonconductor,代码行数:9,代码来源:api.py

示例6: describe_tagged_resource

 def describe_tagged_resource(self, req, resource):
     """Returns a short description of a taggable resource."""
     provider = self._get_provider(resource.realm)
     try:
         return provider.describe_tagged_resource(req, resource)
     except (AttributeError, NotImplementedError):
         # Fallback to resource provider method.
         self.env.log.info('ITagProvider %r does not implement '
                           'describe_tagged_resource()' % provider)
         return get_resource_description(self.env, resource, 'summary')
开发者ID:kzhamaji,项目名称:TracTagsPlugin,代码行数:10,代码来源:api.py

示例7: test_global_neighborhood_report

    def test_global_neighborhood_report(self):
        target = resource.Neighborhood("global", None).child(self.resource)

        self.assertEquals("[global:] report:1", resource.get_resource_description(self.env, target))
        self.assertEquals("[global:] report:1", resource.get_resource_name(self.env, target))
        self.assertEquals("[global:] report:1", resource.get_resource_shortname(self.env, target))
        self.assertEquals("[global:] report:1 at version None", resource.get_resource_summary(self.env, target))
        self.assertEquals(
            "http://example.org/trac.cgi/report/1", resource.get_resource_url(self.env, target, self.env.href)
        )
开发者ID:rvelezc,项目名称:rafaelvelez.us-backup,代码行数:10,代码来源:resource.py

示例8: filter_stream

 def filter_stream(self, req, method, filename, stream, data):
     
     if req.path_info.startswith('/wiki/'):
         if data and data.has_key('page') and hasattr(data['page'], 'resource'):
             title = data['title']
             filter = Transformer('//div[@id="pagepath"]')
             filter = filter.empty()
             filter = filter.append( tag.a( 'wiki:', href = req.href.wiki(), class_ = 'pathentry first' ) )
            
             resource = data['page'].resource
             relation_system = ResourceRelationSystem(self.env)
             tree = relation_system.get_cached_tree(req)    
             add_stylesheet(req, 'wikimenu/css/superfish.css')
             add_script(req, 'wikimenu/js/jquery.bgiframe.min.js')
             add_script(req, 'wikimenu/js/superfish.js')
             add_script(req, 'wikimenu/js/popup.js')
             resources = []
             for res in relation_system.get_ancestors(resource, tree=tree):
                 resources.append(res)
             for res in reversed( resources ):
                 label = get_resource_description(self.env, res)
                 if res.realm=='wiki':
                     if res.id and WikiSystem(self.env).has_page(res.id):
                         
                         menu = tag.ul( )
                                                     
                         for res_child in relation_system.get_children(res):
                             child_label = get_resource_description(self.env, res_child)
                             if res_child.realm=='wiki':
                                 if res_child.id and WikiSystem(self.env).has_page(res_child.id):
                                     anc = tag.a(child_label, href = req.href.wiki(child_label))
                                     menu.append(tag.li( anc ))
                                     
                         
                         filter = filter.append( tag.ul( tag.li( 
                             tag.a(label, href=req.href.wiki(label) ),
                                 menu ), class_= 'wiki_menu' ) )
                         if title != label:
                             filter = filter.append( tag.span( ' / ', 
                                     class_ = 'pathentry sep' ) )
             remove_tran = '//a[@title="View ' + title + '"]'
             return stream | filter
     return stream
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:43,代码来源:wiki.py

示例9: test_product_neighborhood_wiki

    def test_product_neighborhood_wiki(self):
        target = resource.Neighborhood("product", u"xü").child(self.resource)

        self.assertEquals(u"TestPage", resource.get_resource_description(self.env, target))
        self.assertEquals(u"TestPage", resource.get_resource_name(self.env, target))
        self.assertEquals(u"TestPage", resource.get_resource_shortname(self.env, target))
        self.assertEquals(u"TestPage", resource.get_resource_summary(self.env, target))
        self.assertEquals(
            "http://example.org/trac.cgi/products/x%C3%BC/wiki/TestPage?version=2",
            resource.get_resource_url(self.env, target, self.env.href),
        )
开发者ID:rvelezc,项目名称:rafaelvelez.us-backup,代码行数:11,代码来源:resource.py

示例10: test_global_neighborhood_wiki

    def test_global_neighborhood_wiki(self):
        target = resource.Neighborhood("global", None).child(self.resource)

        self.assertEquals("TestPage", resource.get_resource_description(self.env, target))
        self.assertEquals("TestPage", resource.get_resource_name(self.env, target))
        self.assertEquals("TestPage", resource.get_resource_shortname(self.env, target))
        self.assertEquals("TestPage", resource.get_resource_summary(self.env, target))
        self.assertEquals(
            "http://example.org/trac.cgi/wiki/TestPage?version=2",
            resource.get_resource_url(self.env, target, self.env.href),
        )
开发者ID:rvelezc,项目名称:rafaelvelez.us-backup,代码行数:11,代码来源:resource.py

示例11: test_product_neighborhood_report

    def test_product_neighborhood_report(self):
        target = resource.Neighborhood("product", u"xü").child(self.resource)

        self.assertEquals(u"[product:xü] report:1", resource.get_resource_description(self.env, target))
        self.assertEquals(u"[product:xü] report:1", resource.get_resource_name(self.env, target))
        self.assertEquals(u"[product:xü] report:1", resource.get_resource_shortname(self.env, target))
        self.assertEquals(u"[product:xü] report:1 at version None", resource.get_resource_summary(self.env, target))
        self.assertEquals(
            "http://example.org/trac.cgi/products/x%C3%BC/report/1",
            resource.get_resource_url(self.env, target, self.env.href),
        )
开发者ID:rvelezc,项目名称:rafaelvelez.us-backup,代码行数:11,代码来源:resource.py

示例12: test_global_neighborhood_milestone

    def test_global_neighborhood_milestone(self):
        target = resource.Neighborhood("global", None).child(self.resource)

        self.assertEquals("[global:] Milestone milestone1", resource.get_resource_description(self.env, target))
        self.assertEquals("[global:] Milestone milestone1", resource.get_resource_name(self.env, target))
        self.assertEquals("milestone1", resource.get_resource_shortname(self.env, target))
        self.assertEquals("[global:] Milestone milestone1", resource.get_resource_summary(self.env, target))
        self.assertEquals(
            "http://example.org/trac.cgi/milestone/milestone1",
            resource.get_resource_url(self.env, target, self.env.href),
        )
开发者ID:rvelezc,项目名称:rafaelvelez.us-backup,代码行数:11,代码来源:resource.py

示例13: get_resource_description

 def get_resource_description(self, resource, format='default', context=None,
                              **kwargs):
     page = WikiPage(self.env, resource.id)
     if page.exists:
         return get_resource_description(self.env, page.resource, format,
                                         **kwargs)
     rid = to_unicode(resource.id)
     if format in ('compact', 'default'):
         return rid
     else:
         return u'tag:%s' % rid
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:11,代码来源:api.py

示例14: test_resource_source

    def test_resource_source(self):
        res = Resource('source', '/trunk/src')
        self.assertEqual('path /trunk/src',
                         get_resource_description(self.env, res))
        self.assertEqual('/trac.cgi/browser/trunk/src',
                         get_resource_url(self.env, res, self.env.href))

        repo = Resource('repository', 'repo')
        res = Resource('source', '/trunk/src', parent=repo)
        self.assertEqual('path /trunk/src in repo',
                         get_resource_description(self.env, res))
        self.assertEqual('/trac.cgi/browser/repo/trunk/src',
                         get_resource_url(self.env, res, self.env.href))

        repo = Resource('repository', 'repo')
        res = Resource('source', '/trunk/src', version=42, parent=repo)
        self.assertEqual('path /trunk/[email protected] in repo',
                         get_resource_description(self.env, res))
        self.assertEqual('/trac.cgi/browser/repo/trunk/src?rev=42',
                         get_resource_url(self.env, res, self.env.href))
开发者ID:exocad,项目名称:exotrac,代码行数:20,代码来源:api.py

示例15: test_global_neighborhood_ticket

    def test_global_neighborhood_ticket(self):
        nbh = resource.Neighborhood("global", None)
        data = dict(summary="Ticket summary", description="Ticket description", type="enhancement", status="new")
        target = nbh.child("ticket", self._new_ticket(self.global_env, data))

        self.assertEquals("[global:] Ticket #1", resource.get_resource_description(self.env, target))
        self.assertEquals("[global:] Ticket #1", resource.get_resource_name(self.env, target))
        self.assertEquals("[global:] #1", resource.get_resource_shortname(self.env, target))
        self.assertEquals("enhancement: Ticket summary (new)", resource.get_resource_summary(self.env, target))
        self.assertEquals(
            "http://example.org/trac.cgi/ticket/1", resource.get_resource_url(self.env, target, self.env.href)
        )
开发者ID:rvelezc,项目名称:rafaelvelez.us-backup,代码行数:12,代码来源:resource.py


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