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


Python RepositoryManager.get_all_repositories方法代码示例

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


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

示例1: process_request

# 需要导入模块: from trac.versioncontrol.api import RepositoryManager [as 别名]
# 或者: from trac.versioncontrol.api.RepositoryManager import get_all_repositories [as 别名]
    def process_request(self, req):
        req.perm.require('BROWSER_VIEW')

        presel = req.args.get('preselected')
        if presel and (presel + '/').startswith(req.href.browser() + '/'):
            req.redirect(presel)

        path = req.args.get('path', '/')
        rev = req.args.get('rev', '')
        if rev in ('', 'HEAD'):
            rev = None
        order = req.args.get('order', 'name').lower()
        desc = req.args.has_key('desc')
        xhr = req.get_header('X-Requested-With') == 'XMLHttpRequest'
        
        rm = RepositoryManager(self.env)
        all_repositories = rm.get_all_repositories()
        reponame, repos, path = rm.get_repository_by_path(path)

        # Repository index
        show_index = not reponame and path == '/'
        if show_index:
            if repos and (as_bool(all_repositories[''].get('hidden'))
                          or not repos.can_view(req.perm)):
                repos = None

        if not repos and reponame:
            raise ResourceNotFound(_("Repository '%(repo)s' not found",
                                     repo=reponame))

        if reponame and reponame != repos.reponame: # Redirect alias
            qs = req.query_string
            req.redirect(req.href.browser(repos.reponame or None, path)
                         + (qs and '?' + qs or ''))
        reponame = repos and repos.reponame or None
        
        # Find node for the requested path/rev
        context = Context.from_request(req)
        node = None
        display_rev = lambda rev: rev
        if repos:
            try:
                if rev:
                    rev = repos.normalize_rev(rev)
                # If `rev` is `None`, we'll try to reuse `None` consistently,
                # as a special shortcut to the latest revision.
                rev_or_latest = rev or repos.youngest_rev
                node = get_existing_node(req, repos, path, rev_or_latest)
            except NoSuchChangeset, e:
                raise ResourceNotFound(e.message,
                                       _('Invalid changeset number'))

            context = context(repos.resource.child('source', path,
                                                   version=rev_or_latest))
            display_rev = repos.display_rev
开发者ID:zjj,项目名称:trac_hack,代码行数:57,代码来源:browser.py

示例2: expand_macro

# 需要导入模块: from trac.versioncontrol.api import RepositoryManager [as 别名]
# 或者: from trac.versioncontrol.api.RepositoryManager import get_all_repositories [as 别名]
    def expand_macro(self, formatter, name, content):
        args, kwargs = parse_args(content)
        format = kwargs.get('format', 'compact')
        glob = kwargs.get('glob', '*')
        order = kwargs.get('order')
        desc = as_bool(kwargs.get('desc', 0))

        rm = RepositoryManager(self.env)
        all_repos = dict(rdata for rdata in rm.get_all_repositories().items()
                         if fnmatchcase(rdata[0], glob))

        if format == 'table':
            repo = self._render_repository_index(formatter.context, all_repos,
                                                 order, desc)

            add_stylesheet(formatter.req, 'common/css/browser.css')
            wiki_format_messages = self.config['changeset'] \
                                       .getbool('wiki_format_messages')
            data = {'repo': repo, 'order': order, 'desc': desc and 1 or None,
                    'reponame': None, 'path': '/', 'stickyrev': None,
                    'wiki_format_messages': wiki_format_messages}
            from trac.web.chrome import Chrome
            return Chrome(self.env).render_template(
                    formatter.req, 'repository_index.html', data, None,
                    fragment=True)

        def get_repository(reponame):
            try:
                return rm.get_repository(reponame)
            except TracError:
                return

        all_repos = [(reponame, get_repository(reponame))
                     for reponame in all_repos]
        all_repos = sorted(((reponame, repos) for reponame, repos in all_repos
                            if repos
                            and not as_bool(repos.params.get('hidden'))
                            and repos.can_view(formatter.perm)),
                           reverse=desc)

        def repolink(reponame, repos):
            label = reponame or _('(default)')
            return Markup(tag.a(label, 
                          title=_('View repository %(repo)s', repo=label),
                          href=formatter.href.browser(repos.reponame or None)))

        if format == 'list':
            return tag.dl([
                tag(tag.dt(repolink(reponame, repos)),
                    tag.dd(repos.params.get('description')))
                for reponame, repos in all_repos])
        else: # compact
            return Markup(', ').join([repolink(reponame, repos)
                                      for reponame, repos in all_repos])
开发者ID:zjj,项目名称:trac_hack,代码行数:56,代码来源:browser.py

示例3: get_revtree

# 需要导入模块: from trac.versioncontrol.api import RepositoryManager [as 别名]
# 或者: from trac.versioncontrol.api.RepositoryManager import get_all_repositories [as 别名]
    def get_revtree(self, repos, req):
        rm = RepositoryManager(self.env)
        reps = rm.get_all_repositories()
        for repo in reps:
            rtype = reps[repo].get('type', None) or rm.default_repository_type
            if rtype == 'svn':
                break
        else:
            raise TracError("Revtree only supports Subversion repositories")

        self.env.log.debug("Enhancers: %s" % self.enhancers)

        return SvgRevtree(self.env, repos, req.href(),
                          self.enhancers, self.optimizer)
开发者ID:ebouaziz,项目名称:TracRevTreePlugin,代码行数:16,代码来源:api.py

示例4: help

# 需要导入模块: from trac.versioncontrol.api import RepositoryManager [as 别名]
# 或者: from trac.versioncontrol.api.RepositoryManager import get_all_repositories [as 别名]
    def help(self, req):

        rm = RepositoryManager(self.env)
        all_repositories = rm.get_all_repositories()
        page = _('= Repositories =') + '\n'

        for reponame, repoinfo in all_repositories.iteritems():
          path = '%s/dav/%s' % (req.base_path, reponame)
          url = '%s://%[email protected]%s:%s%s' % (req.scheme, req.remote_user, req.server_name, req.server_port, path)
          url = urlparse.urlparse(url)
          self.log.info('repo %r', repoinfo)
          page += ' == %s == \r\n {{{\n %s %s \n}}}\n\n' % (reponame, self.helper_vcs(repoinfo['type']), url.geturl())

        data = {
            'proxydav_title': _('Repo access'), 
            'proxydav_page': self.format_to_html(req, page)
        }
        return 'proxydav.html', data, None
开发者ID:castorinop,项目名称:proxydav,代码行数:20,代码来源:web_ui.py

示例5: get_repo

# 需要导入模块: from trac.versioncontrol.api import RepositoryManager [as 别名]
# 或者: from trac.versioncontrol.api.RepositoryManager import get_all_repositories [as 别名]
 def get_repo(self, req):
     reponame = self.get_repo_name(req)
     self.log.info('repo %r', reponame)
     rm = RepositoryManager(self.env)
     repoinfo = rm.get_all_repositories().get(reponame, {})
     return repoinfo
开发者ID:castorinop,项目名称:proxydav,代码行数:8,代码来源:web_ui.py

示例6: expand_macro

# 需要导入模块: from trac.versioncontrol.api import RepositoryManager [as 别名]
# 或者: from trac.versioncontrol.api.RepositoryManager import get_all_repositories [as 别名]
    def expand_macro(self, formatter, name, content):
        args, kwargs = parse_args(content)
        format = kwargs.get("format", "compact")
        glob = kwargs.get("glob", "*")
        order = kwargs.get("order")
        desc = as_bool(kwargs.get("desc", 0))

        rm = RepositoryManager(self.env)
        all_repos = dict(rdata for rdata in rm.get_all_repositories().items() if fnmatchcase(rdata[0], glob))

        if format == "table":
            repo = self._render_repository_index(formatter.context, all_repos, order, desc)

            add_stylesheet(formatter.req, "common/css/browser.css")
            wiki_format_messages = self.config["changeset"].getbool("wiki_format_messages")
            data = {
                "repo": repo,
                "order": order,
                "desc": 1 if desc else None,
                "reponame": None,
                "path": "/",
                "stickyrev": None,
                "wiki_format_messages": wiki_format_messages,
            }
            from trac.web.chrome import Chrome

            return Chrome(self.env).render_template(formatter.req, "repository_index.html", data, None, fragment=True)

        def get_repository(reponame):
            try:
                return rm.get_repository(reponame)
            except TracError:
                return

        all_repos = [(reponame, get_repository(reponame)) for reponame in all_repos]
        all_repos = sorted(
            (
                (reponame, repos)
                for reponame, repos in all_repos
                if repos and not as_bool(repos.params.get("hidden")) and repos.is_viewable(formatter.perm)
            ),
            reverse=desc,
        )

        def repolink(reponame, repos):
            label = reponame or _("(default)")
            return Markup(
                tag.a(
                    label,
                    title=_("View repository %(repo)s", repo=label),
                    href=formatter.href.browser(repos.reponame or None),
                )
            )

        if format == "list":
            return tag.dl(
                [
                    tag(tag.dt(repolink(reponame, repos)), tag.dd(repos.params.get("description")))
                    for reponame, repos in all_repos
                ]
            )
        else:  # compact
            return Markup(", ").join([repolink(reponame, repos) for reponame, repos in all_repos])
开发者ID:pkdevbox,项目名称:trac,代码行数:65,代码来源:browser.py

示例7: process_request

# 需要导入模块: from trac.versioncontrol.api import RepositoryManager [as 别名]
# 或者: from trac.versioncontrol.api.RepositoryManager import get_all_repositories [as 别名]
    def process_request(self, req):
        presel = req.args.get("preselected")
        if presel and (presel + "/").startswith(req.href.browser() + "/"):
            req.redirect(presel)

        path = req.args.get("path", "/")
        rev = req.args.get("rev", "")
        if rev.lower() in ("", "head"):
            rev = None
        format = req.args.get("format")
        order = req.args.get("order", "name").lower()
        desc = "desc" in req.args

        rm = RepositoryManager(self.env)
        all_repositories = rm.get_all_repositories()
        reponame, repos, path = rm.get_repository_by_path(path)

        # Repository index
        show_index = not reponame and path == "/"
        if show_index:
            if repos and (as_bool(all_repositories[""].get("hidden")) or not repos.is_viewable(req.perm)):
                repos = None

        if not repos and reponame:
            raise ResourceNotFound(_("Repository '%(repo)s' not found", repo=reponame))

        if reponame and reponame != repos.reponame:  # Redirect alias
            qs = req.query_string
            req.redirect(req.href.browser(repos.reponame or None, path) + ("?" + qs if qs else ""))
        reponame = repos.reponame if repos else None

        # Find node for the requested path/rev
        context = web_context(req)
        node = None
        changeset = None
        display_rev = lambda rev: rev
        if repos:
            try:
                if rev:
                    rev = repos.normalize_rev(rev)
                # If `rev` is `None`, we'll try to reuse `None` consistently,
                # as a special shortcut to the latest revision.
                rev_or_latest = rev or repos.youngest_rev
                node = get_existing_node(req, repos, path, rev_or_latest)
            except NoSuchChangeset as e:
                raise ResourceNotFound(e, _("Invalid changeset number"))
            if node:
                try:
                    # use changeset instance to retrieve branches and tags
                    changeset = repos.get_changeset(node.rev)
                except NoSuchChangeset:
                    pass

            context = context.child(repos.resource.child(self.realm, path, version=rev_or_latest))
            display_rev = repos.display_rev

        # Prepare template data
        path_links = get_path_links(req.href, reponame, path, rev, order, desc)

        repo_data = dir_data = file_data = None
        if show_index:
            repo_data = self._render_repository_index(context, all_repositories, order, desc)
        if node:
            if not node.is_viewable(req.perm):
                raise PermissionError("BROWSER_VIEW" if node.isdir else "FILE_VIEW", node.resource, self.env)
            if node.isdir:
                if format in ("zip",):  # extension point here...
                    self._render_zip(req, context, repos, node, rev)
                    # not reached
                dir_data = self._render_dir(req, repos, node, rev, order, desc)
            elif node.isfile:
                file_data = self._render_file(req, context, repos, node, rev)

        if not repos and not (repo_data and repo_data["repositories"]):
            # If no viewable repositories, check permission instead of
            # repos.is_viewable()
            req.perm.require("BROWSER_VIEW")
            if show_index:
                raise ResourceNotFound(_("No viewable repositories"))
            else:
                raise ResourceNotFound(_("No node %(path)s", path=path))

        quickjump_data = properties_data = None
        if node and not req.is_xhr:
            properties_data = self.render_properties("browser", context, node.get_properties())
            quickjump_data = list(repos.get_quickjump_entries(rev))

        data = {
            "context": context,
            "reponame": reponame,
            "repos": repos,
            "repoinfo": all_repositories.get(reponame or ""),
            "path": path,
            "rev": node and node.rev,
            "stickyrev": rev,
            "display_rev": display_rev,
            "changeset": changeset,
            "created_path": node and node.created_path,
            "created_rev": node and node.created_rev,
            "properties": properties_data,
#.........这里部分代码省略.........
开发者ID:pkdevbox,项目名称:trac,代码行数:103,代码来源:browser.py

示例8: process_request

# 需要导入模块: from trac.versioncontrol.api import RepositoryManager [as 别名]
# 或者: from trac.versioncontrol.api.RepositoryManager import get_all_repositories [as 别名]
    def process_request(self, req):
        strategy = req.args.get('strategy')
        term = req.args.get('q')

        if strategy == 'linkresolvers':
            wiki = WikiSystem(self.env)
            completions = []
            for provider in wiki.syntax_providers:
                for name, resolver in provider.get_link_resolvers():
                    if name.startswith(term):
                        completions.append(name)
            self._send_json(req, completions)

        elif strategy == 'ticket':
            with self.env.db_query as db:
                rows = db("""
                    SELECT id, summary
                    FROM ticket
                    WHERE %s %s
                    ORDER BY changetime DESC
                    LIMIT 10
                    """ % (db.cast('id', 'text'), db.prefix_match()),
                    (db.prefix_match_value(term), ))
            completions = [{
                'id': row[0],
                'summary': row[1],
                } for row in rows
                if 'TICKET_VIEW' in req.perm(Resource('ticket', row[0]))]
            self._send_json(req, completions)

        elif strategy == 'wikipage':
            with self.env.db_query as db:
                rows = db("""
                    SELECT name
                    FROM wiki
                    WHERE name %s
                    GROUP BY name
                    ORDER BY name
                    LIMIT 10
                    """ % db.prefix_match(),
                    (db.prefix_match_value(term), ))
            completions = [row[0] for row in rows
                           if 'WIKI_VIEW' in req.perm(Resource('wiki', row[0]))]
            self._send_json(req, completions)

        elif strategy == 'macro':
            resource = Resource()
            context = web_context(req, resource)
            wiki = WikiSystem(self.env)
            macros = []
            for provider in wiki.macro_providers:
                names = list(provider.get_macros() or [])
                for name in names:
                    if name.startswith(term):
                        macros.append((name, provider))
            completions = []
            if len(macros) == 1:
                name, provider = macros[0]
                descr = provider.get_macro_description(name)
                if isinstance(descr, (tuple, list)):
                    descr = dgettext(descr[0], to_unicode(descr[1]))
                descr = format_to_html(self.env, context, descr)
                completions.append({
                    'name': name,
                    'description': descr,
                })
            else:
                for name, provider in macros:
                    descr = provider.get_macro_description(name)
                    if isinstance(descr, (tuple, list)):
                        descr = dgettext(descr[0], to_unicode(descr[1]))
                    descr = format_to_oneliner(self.env, context, descr, shorten=True)
                    completions.append({
                        'name': name,
                        'description': descr,
                    })
            self._send_json(req, completions)

        elif strategy == 'source':
            rm = RepositoryManager(self.env)
            completions = []
            if term.find('/') == -1:
                for reponame, repoinfo in rm.get_all_repositories().iteritems():
                    if 'BROWSER_VIEW' in req.perm(Resource('repository', reponame)):
                        if len(term) == 0 or reponame.lower().startswith(term.lower()):
                            completions.append(reponame+'/')
            else:
                reponame, path = term.split('/', 1)
                repos = rm.get_repository(reponame)
                if repos is not None:
                    if path.find('@') != -1:
                        path, search_rev = path.rsplit('@', 1)
                        node = repos.get_node(path, repos.youngest_rev)
                        if node.can_view(req.perm):
                            for r in node.get_history(10):
                                if str(r[1]).startswith(search_rev):
                                    completions.append('%s/%[email protected]%s' % (reponame, path, r[1]))
                    else:
                        if path.find('/') != -1:
                            dir, filename = path.rsplit('/', 1)
#.........这里部分代码省略.........
开发者ID:kzhamaji,项目名称:WikiAutoCompletePlugin,代码行数:103,代码来源:web_ui.py


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