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


Python RepositoryManager.get_default_repository方法代码示例

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


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

示例1: _format_link

# 需要导入模块: from trac.versioncontrol.api import RepositoryManager [as 别名]
# 或者: from trac.versioncontrol.api.RepositoryManager import get_default_repository [as 别名]
    def _format_link(self, formatter, ns, match, label, fullmatch=None):
        if ns == 'log1':
            groups = fullmatch.groupdict()
            it_log = groups.get('it_log')
            revs = groups.get('log_revs')
            path = groups.get('log_path') or '/'
            target = '%s%[email protected]%s' % (it_log, path, revs)
            # prepending it_log is needed, as the helper expects it there
            intertrac = formatter.shorthand_intertrac_helper(
                'log', target, label, fullmatch)
            if intertrac:
                return intertrac
            path, query, fragment = formatter.split_link(path)
        else:
            assert ns in ('log', 'log2')
            if ns == 'log':
                match, query, fragment = formatter.split_link(match)
            else:
                query = fragment = ''
                match = ''.join(reversed(match.split('/', 1)))
            path = match
            revs = ''
            if self.LOG_LINK_RE.match(match):
                indexes = [sep in match and match.index(sep) for sep in ':@']
                idx = min([i for i in indexes if i is not False])
                path, revs = match[:idx], match[idx+1:]

        rm = RepositoryManager(self.env)
        try:
            reponame, repos, path = rm.get_repository_by_path(path)
            if not reponame:
                reponame = rm.get_default_repository(formatter.context)
                if reponame is not None:
                    repos = rm.get_repository(reponame)

            if repos:
                if 'LOG_VIEW' in formatter.perm:
                    reponame = repos.reponame or None
                    path = path or '/'
                    revranges = RevRanges(repos, revs)
                    if revranges.has_ranges():
                        href = formatter.href.log(reponame, path,
                                                  revs=unicode(revranges))
                    else:
                        # try to resolve if single rev
                        repos.normalize_rev(revs)
                        href = formatter.href.log(reponame, path,
                                                  rev=revs or None)
                    if query and '?' in href:
                        query = '&' + query[1:]
                    return tag.a(label, class_='source',
                                 href=href + query + fragment)
                errmsg = _("No permission to view change log")
            elif reponame:
                errmsg = _("Repository '%(repo)s' not found", repo=reponame)
            else:
                errmsg = _("No default repository defined")
        except TracError, e:
            errmsg = to_unicode(e)
开发者ID:exocad,项目名称:exotrac,代码行数:61,代码来源:log.py

示例2: _format_link

# 需要导入模块: from trac.versioncontrol.api import RepositoryManager [as 别名]
# 或者: from trac.versioncontrol.api.RepositoryManager import get_default_repository [as 别名]
    def _format_link(self, formatter, ns, match, label, fullmatch=None):
        if ns == "log1":
            groups = fullmatch.groupdict()
            it_log = groups.get("it_log")
            revs = groups.get("log_revs")
            path = groups.get("log_path") or "/"
            target = "%s%[email protected]%s" % (it_log, path, revs)
            # prepending it_log is needed, as the helper expects it there
            intertrac = formatter.shorthand_intertrac_helper("log", target, label, fullmatch)
            if intertrac:
                return intertrac
            path, query, fragment = formatter.split_link(path)
        else:
            assert ns in ("log", "log2")
            if ns == "log":
                match, query, fragment = formatter.split_link(match)
            else:
                query = fragment = ""
                match = "".join(reversed(match.split("/", 1)))
            path = match
            revs = ""
            if self.LOG_LINK_RE.match(match):
                indexes = [sep in match and match.index(sep) for sep in ":@"]
                idx = min([i for i in indexes if i is not False])
                path, revs = match[:idx], match[idx + 1 :]

        rm = RepositoryManager(self.env)
        try:
            reponame, repos, path = rm.get_repository_by_path(path)
            if not reponame:
                reponame = rm.get_default_repository(formatter.context)
                if reponame is not None:
                    repos = rm.get_repository(reponame)

            if repos:
                if "LOG_VIEW" in formatter.perm:
                    reponame = repos.reponame or None
                    path = path or "/"
                    revranges = RevRanges(repos, revs)
                    if revranges.has_ranges():
                        href = formatter.href.log(reponame, path, revs=unicode(revranges))
                    else:
                        # try to resolve if single rev
                        repos.normalize_rev(revs)
                        href = formatter.href.log(reponame, path, rev=revs or None)
                    if query and "?" in href:
                        query = "&" + query[1:]
                    return tag.a(label, class_="source", href=href + query + fragment)
                errmsg = _("No permission to view change log")
            elif reponame:
                errmsg = _("Repository '%(repo)s' not found", repo=reponame)
            else:
                errmsg = _("No default repository defined")
        except TracError as e:
            errmsg = to_unicode(e)
        return tag.a(label, class_="missing source", title=errmsg)
开发者ID:pkdevbox,项目名称:trac,代码行数:58,代码来源:log.py


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