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


Python utils.safe_unicode函数代码示例

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


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

示例1: name

 def name(self):
     """
     Returns name of the node so if its path
     then only last part is returned.
     """
     org = safe_unicode(self.path.rstrip('/').split('/')[-1])
     return u'%s @ %s' % (org, self.changeset.short_id)
开发者ID:Lothiraldan,项目名称:vcs,代码行数:7,代码来源:nodes.py

示例2: description

 def description(self):
     undefined_description = u'unknown'
     description_path = os.path.join(self.path, '.git', 'description')
     if os.path.isfile(description_path):
         return safe_unicode(open(description_path).read())
     else:
         return undefined_description
开发者ID:methane,项目名称:vcs,代码行数:7,代码来源:repository.py

示例3: branches

    def branches(self):
        """
        Get's branches for this repository
        """

        if self._empty:
            return {}

        def _branchtags(localrepo):
            """
            Patched version of mercurial branchtags to not return the closed
            branches

            :param localrepo: locarepository instance
            """

            bt = {}
            for bn, heads in localrepo.branchmap().iteritems():
                tip = heads[-1]
                if "close" not in localrepo.changelog.read(tip)[5]:
                    bt[bn] = tip
            return bt

        sortkey = lambda ctx: ctx[0]  # sort by name
        _branches = [(safe_unicode(n), hex(h)) for n, h in _branchtags(self._repo).items()]

        return OrderedDict(sorted(_branches, key=sortkey, reverse=False))
开发者ID:lukaszb,项目名称:vcs,代码行数:27,代码来源:hg.py

示例4: branch

    def branch(self):

        heads = self.repository._heads(reverse=False)

        ref = heads.get(self.raw_id)
        if ref:
            return safe_unicode(ref)
开发者ID:Lothiraldan,项目名称:vcs,代码行数:7,代码来源:changeset.py

示例5: __init__

    def __init__(self, repository, revision):
        self._stat_modes = {}
        self.repository = repository
        self.raw_id = revision
        self.revision = repository.revisions.index(revision)

        self.short_id = self.raw_id[:12]
        self.id = self.raw_id
        try:
            commit = self.repository._repo.get_object(self.raw_id)
        except KeyError:
            raise RepositoryError("Cannot get object with id %s" % self.raw_id)
        self._commit = commit
        self._tree_id = commit.tree

        try:
            self.message = safe_unicode(commit.message[:-1])
            # Always strip last eol
        except UnicodeDecodeError:
            self.message = commit.message[:-1].decode(commit.encoding
                or 'utf-8')
        #self.branch = None
        self.tags = []
        #tree = self.repository.get_object(self._tree_id)
        self.nodes = {}
        self._paths = {}
开发者ID:methane,项目名称:vcs,代码行数:26,代码来源:changeset.py

示例6: _get_bookmarks

    def _get_bookmarks(self):
        if self._empty:
            return {}

        sortkey = lambda ctx: ctx[0]  # sort by name
        _bookmarks = [(safe_unicode(n), hex(h),) for n, h in
                 self._repo._bookmarks.items()]
        return OrderedDict(sorted(_bookmarks, key=sortkey, reverse=True))
开发者ID:cloudfoundry,项目名称:python-buildpack,代码行数:8,代码来源:repository.py

示例7: description

 def description(self):
     idx_loc = '' if self.bare else '.git'
     undefined_description = u'unknown'
     description_path = os.path.join(self.path, idx_loc, 'description')
     if os.path.isfile(description_path):
         return safe_unicode(open(description_path).read())
     else:
         return undefined_description
开发者ID:cloudfoundry,项目名称:python-buildpack,代码行数:8,代码来源:repository.py

示例8: content

    def content(self):
        """
        Returns lazily content of the FileNode. If possible, would try to
        decode content from UTF-8.
        """
        content = self._get_content()

        if bool(content and '\0' in content):
            return content
        return safe_unicode(content)
开发者ID:Lothiraldan,项目名称:vcs,代码行数:10,代码来源:nodes.py

示例9: content

    def content(self):
        """
        Returns lazily content of the FileNode. If possible, would try to
        decode content from UTF-8.
        """
        if self.changeset:
            content = self.changeset.get_file_content(self.path)
        else:
            content = self._content

        if bool(content and '\0' in content):
            return content
        return safe_unicode(content)
开发者ID:jonashaag,项目名称:vcs,代码行数:13,代码来源:nodes.py

示例10: branch

    def branch(self):
        # TODO: Cache as we walk (id <-> branch name mapping)
        refs = self.repository._repo.get_refs()
        heads = [(key[len('refs/heads/'):], val) for key, val in refs.items()
            if key.startswith('refs/heads/')]

        for name, id in heads:
            walker = self.repository._repo.object_store.get_graph_walker([id])
            while True:
                id = walker.next()
                if not id:
                    break
                if id == self.id:
                    return safe_unicode(name)
        raise ChangesetError("This should not happen... Have you manually "
            "change id of the changeset?")
开发者ID:methane,项目名称:vcs,代码行数:16,代码来源:changeset.py

示例11: _get_branches

    def _get_branches(self, closed=False):
        """
        Get's branches for this repository
        Returns only not closed branches by default

        :param closed: return also closed branches for mercurial
        """

        if self._empty:
            return {}

        def _branchtags(localrepo):
            """
            Patched version of mercurial branchtags to not return the closed
            branches

            :param localrepo: locarepository instance
            """

            bt = {}
            bt_closed = {}
            for bn, heads in localrepo.branchmap().iteritems():
                tip = heads[-1]
                if 'close' in localrepo.changelog.read(tip)[5]:
                    bt_closed[bn] = tip
                else:
                    bt[bn] = tip

            if closed:
                bt.update(bt_closed)
            return bt

        sortkey = lambda ctx: ctx[0]  # sort by name
        _branches = [(safe_unicode(n), hex(h),) for n, h in
                     _branchtags(self._repo).items()]

        return OrderedDict(sorted(_branches, key=sortkey, reverse=False))
开发者ID:cloudfoundry,项目名称:python-buildpack,代码行数:37,代码来源:repository.py

示例12: author

 def author(self):
     return safe_unicode(self._ctx.user())
开发者ID:stardust85,项目名称:vcs,代码行数:2,代码来源:changeset.py

示例13: author

 def author(self):
     return safe_unicode(getattr(self._commit, self._author_property))
开发者ID:Lothiraldan,项目名称:vcs,代码行数:2,代码来源:changeset.py

示例14: line_decoder

 def line_decoder(l):
     if l.startswith('+') and not l.startswith('+++'):
         self.adds += 1
     elif l.startswith('-') and not l.startswith('---'):
         self.removes += 1
     return safe_unicode(l)
开发者ID:cloudfoundry,项目名称:python-buildpack,代码行数:6,代码来源:diffs.py

示例15: unicode_path

 def unicode_path(self):
     return safe_unicode(self.path)
开发者ID:Lothiraldan,项目名称:vcs,代码行数:2,代码来源:nodes.py


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