• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python encoding.tolocal函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: read

def read(repo):
    '''Parse .hg/bookmarks file and return a dictionary

    Bookmarks are stored as {HASH}\\s{NAME}\\n (localtags format) values
    in the .hg/bookmarks file.
    Read the file and return a (name=>nodeid) dictionary
    '''
    bookmarks = {}
    try:
        for line in repo.opener('bookmarks'):
            line = line.strip()
            if not line:
                continue
            if ' ' not in line:
                repo.ui.warn(_('malformed line in .hg/bookmarks: %r\n') % line)
                continue
            sha, refspec = line.split(' ', 1)
            refspec = encoding.tolocal(refspec)
            try:
                bookmarks[refspec] = repo.changelog.lookup(sha)
            except error.RepoLookupError:
                pass
    except IOError, inst:
        if inst.errno != errno.ENOENT:
            raise
开发者ID:agbiotec,项目名称:galaxy-tools-vcr,代码行数:25,代码来源:bookmarks.py


示例2: localbranches

 def localbranches(self):
     branches = []
     bdir = self.join('branches')
     if os.path.isdir(bdir):
         for d in os.listdir(bdir):
             branches.append(encoding.tolocal(store.decodefilename(d)))
     return branches
开发者ID:jmurty,项目名称:dotfiles,代码行数:7,代码来源:localbranch.py


示例3: remotelookup

def remotelookup(orig, repo, proto, key):
    k = encoding.tolocal(key)
    if k.startswith('_gitlookup_'):
        ret = _dolookup(repo, k)
        if ret is not None:
            success = 1
            return '%s %s\n' % (success, ret)
    return orig(repo, proto, key)
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:8,代码来源:gitlookup.py


示例4: rewrite_commit_descriptions

def rewrite_commit_descriptions(ui, repo, node, descriptions=None):
    if not node:
        node = 'tip'

    ctx = repo[node]
    nodes = [ctx.node()]
    for ancestor in ctx.ancestors():
        ctx = repo[ancestor]
        if ctx.phase() != phases.draft:
            break
        nodes.append(ctx.node())
    nodes.reverse()

    description_map = {}
    with open(descriptions, 'rb') as f:
        raw_descriptions = json.load(f)
        for k in raw_descriptions:
            description_map[k] = encoding.tolocal(raw_descriptions[k].encode('utf-8'))

    def prune_unchanged(node):
        sha1 = repo[node].hex()[:12]
        description = repo[node].description()
        revised_description = description_map.get(sha1, description)
        if description == revised_description:
            ui.write(_('not rewriting %s - description unchanged\n' % sha1))
            return False
        return True

    nodes = filter(prune_unchanged, nodes)
    if not nodes:
        ui.write(_('no commits found to be rewritten\n'))
        return 1

    def createfn(repo, ctx, revmap, filectxfn):
        parents = rewrite.newparents(repo, ctx, revmap)

        sha1 = ctx.hex()[:12]
        if sha1 in description_map:
            description = description_map[sha1]
        else:
            description = ctx.description()

        memctx = context.memctx(repo, parents, description,
                                ctx.files(), filectxfn, user=ctx.user(),
                                date=ctx.date(), extra=ctx.extra())
        status = ctx.p1().status(ctx)
        memctx.modified = lambda: status[0]
        memctx.added = lambda: status[1]
        memctx.removed = lambda: status[2]

        return memctx

    rewrite.replacechangesets(repo, nodes, createfn)
开发者ID:frostytear,项目名称:version-control-tools,代码行数:53,代码来源:rewritecommitdescriptions.py


示例5: makememctx

    def makememctx(repo, ctx, revmap, copyfilectxfn):
        parents = newparents(repo, ctx, revmap)
        # Need to make a copy otherwise modification is made on original,
        # which is just plain wrong.
        msg = encoding.fromlocal(ctx.description())
        new_msg, changed = addcommitid(msg, repo=repo)

        memctx = context.memctx(repo, parents,
                                encoding.tolocal(new_msg), ctx.files(),
                                copyfilectxfn, user=ctx.user(),
                                date=ctx.date(), extra=dict(ctx.extra()))

        return memctx
开发者ID:pkdevboxy,项目名称:version-control-tools,代码行数:13,代码来源:client.py


示例6: geturl

def geturl(path):
    try:
        return svn.client.url_from_path(svn.core.svn_path_canonicalize(path))
    except SubversionException:
        pass
    if os.path.isdir(path):
        path = os.path.normpath(os.path.abspath(path))
        if os.name == 'nt':
            path = '/' + util.normpath(path)
        # Module URL is later compared with the repository URL returned
        # by svn API, which is UTF-8.
        path = encoding.tolocal(path)
        return 'file://%s' % urllib.quote(path)
    return path
开发者ID:iluxa-c0m,项目名称:mercurial-crew-tonfa,代码行数:14,代码来源:subversion.py


示例7: __init__

    def __init__(self, repo):
        dict.__init__(self)
        self._repo = repo

        try:
            for line in repo.vfs('remoterefs'):
                line = line.strip()
                if not line:
                    continue

                sha, ref = line.split(None, 1)
                ref = encoding.tolocal(ref)
                try:
                    self[ref] = repo.changelog.lookup(sha)
                except LookupError:
                    pass

        except IOError as e:
            if e.errno != errno.ENOENT:
                raise
开发者ID:armenzg,项目名称:version-control-tools,代码行数:20,代码来源:__init__.py


示例8: __init__

 def __init__(self, repo):
     dict.__init__(self)
     self._repo = repo
     try:
         bkfile = self.getbkfile(repo)
         for line in bkfile:
             line = line.strip()
             if not line:
                 continue
             if " " not in line:
                 repo.ui.warn(_("malformed line in .hg/bookmarks: %r\n") % line)
                 continue
             sha, refspec = line.split(" ", 1)
             refspec = encoding.tolocal(refspec)
             try:
                 self[refspec] = repo.changelog.lookup(sha)
             except LookupError:
                 pass
     except IOError, inst:
         if inst.errno != errno.ENOENT:
             raise
开发者ID:areshero,项目名称:ThirdWorldApp,代码行数:21,代码来源:bookmarks.py


示例9: __init__

 def __init__(self, repo):
     dict.__init__(self)
     self._repo = repo
     try:
         for line in repo.vfs('bookmarks'):
             line = line.strip()
             if not line:
                 continue
             if ' ' not in line:
                 repo.ui.warn(_('malformed line in .hg/bookmarks: %r\n')
                              % line)
                 continue
             sha, refspec = line.split(' ', 1)
             refspec = encoding.tolocal(refspec)
             try:
                 self[refspec] = repo.changelog.lookup(sha)
             except LookupError:
                 pass
     except IOError, inst:
         if inst.errno != errno.ENOENT:
             raise
开发者ID:spraints,项目名称:for-example,代码行数:21,代码来源:bookmarks.py


示例10: manifest

 def manifest(self):
     # As of svn 1.7, the "add" command fails when receiving
     # already tracked entries, so we have to track and filter them
     # ourselves.
     m = set()
     output = self.run0('ls', recursive=True, xml=True)
     doc = xml.dom.minidom.parseString(output)
     for e in doc.getElementsByTagName('entry'):
         for n in e.childNodes:
             if n.nodeType != n.ELEMENT_NODE or n.tagName != 'name':
                 continue
             name = ''.join(c.data for c in n.childNodes
                            if c.nodeType == c.TEXT_NODE)
             # Entries are compared with names coming from
             # mercurial, so bytes with undefined encoding. Our
             # best bet is to assume they are in local
             # encoding. They will be passed to command line calls
             # later anyway, so they better be.
             m.add(encoding.tolocal(name.encode('utf-8')))
             break
     return m
开发者ID:chuchiperriman,项目名称:hg-stable,代码行数:21,代码来源:subversion.py


示例11: readactive

def readactive(repo):
    """
    Get the active bookmark. We can have an active bookmark that updates
    itself as we commit. This function returns the name of that bookmark.
    It is stored in .hg/bookmarks.current
    """
    mark = None
    try:
        file = repo.vfs('bookmarks.current')
    except IOError as inst:
        if inst.errno != errno.ENOENT:
            raise
        return None
    try:
        # No readline() in osutil.posixfile, reading everything is cheap
        mark = encoding.tolocal((file.readlines() or [''])[0])
        if mark == '' or mark not in repo._bookmarks:
            mark = None
    finally:
        file.close()
    return mark
开发者ID:pierfort123,项目名称:mercurial,代码行数:21,代码来源:bookmarks.py


示例12: pygmentize

def pygmentize(field, fctx, style, tmpl):

    # append a <link ...> to the syntax highlighting css
    old_header = ''.join(tmpl('header'))
    if SYNTAX_CSS not in old_header:
        new_header =  old_header + SYNTAX_CSS
        tmpl.cache['header'] = new_header

    text = fctx.data()
    if util.binary(text):
        return

    # avoid UnicodeDecodeError in pygments
    text = encoding.tolocal(text)

    # To get multi-line strings right, we can't format line-by-line
    try:
        lexer = guess_lexer_for_filename(fctx.path(), text[:1024],
                                         encoding=encoding.encoding)
    except (ClassNotFound, ValueError):
        try:
            lexer = guess_lexer(text[:1024], encoding=encoding.encoding)
        except (ClassNotFound, ValueError):
            lexer = TextLexer(encoding=encoding.encoding)

    formatter = HtmlFormatter(style=style, encoding=encoding.encoding)

    colorized = highlight(text, lexer, formatter)
    # strip wrapping div
    colorized = colorized[:colorized.find('\n</pre>')]
    colorized = colorized[colorized.find('<pre>')+5:]
    coloriter = iter(colorized.splitlines())

    tmpl.filters['colorize'] = lambda x: coloriter.next()

    oldl = tmpl.cache[field]
    newl = oldl.replace('line|escape', 'line|colorize')
    tmpl.cache[field] = newl
开发者ID:Nurb432,项目名称:plan9front,代码行数:38,代码来源:highlight.py


示例13: u2hg

def u2hg(s):
    """Returns a mercurial string representing an unicode object."""
    return encoding.tolocal(s.encode("utf-8"))
开发者ID:GoGoBunny,项目名称:blohg,代码行数:3,代码来源:utils.py


示例14: open

u = ui.ui()

repo = hg.repository(u, 'test1', create=1)
os.chdir('test1')

# create 'foo' with fixed time stamp
f = open('foo', 'w')
f.write('foo\n')
f.close()
os.utime('foo', (1000, 1000))

# add+commit 'foo'
repo[None].add(['foo'])
repo.commit(text='commit1', date="0 0")

print "workingfilectx.date =", repo[None]['foo'].date()

# test memctx with non-ASCII commit message

def filectxfn(repo, memctx, path):
    return context.memfilectx("foo", "")

ctx = context.memctx(repo, ['tip', None],
                     encoding.tolocal("Gr\xc3\xbcezi!"),
                     ["foo"], filectxfn)
ctx.commit()
for enc in "ASCII", "Latin-1", "UTF-8":
    encoding.encoding = enc
    print "%-8s: %s" % (enc, repo["tip"].description())
开发者ID:chuchiperriman,项目名称:hg-stable,代码行数:29,代码来源:test-context.py


示例15: readline

    '''Get the current bookmark

    If we use gittishsh branches we have a current bookmark that
    we are on. This function returns the name of the bookmark. It
    is stored in .hg/bookmarks.current
    '''
    mark = None
    try:
        file = repo.opener('bookmarks.current')
    except IOError, inst:
        if inst.errno != errno.ENOENT:
            raise
        return None
    try:
        # No readline() in posixfile_nt, reading everything is cheap
        mark = encoding.tolocal((file.readlines() or [''])[0])
        if mark == '' or mark not in repo._bookmarks:
            mark = None
    finally:
        file.close()
    return mark

def write(repo):
    '''Write bookmarks

    Write the given bookmark => hash dictionary to the .hg/bookmarks file
    in a format equal to those of localtags.

    We also store a backup of the previous state in undo.bookmarks that
    can be copied back on rollback.
    '''
开发者ID:agbiotec,项目名称:galaxy-tools-vcr,代码行数:31,代码来源:bookmarks.py


示例16: getlocalbranch

 def getlocalbranch(self):
     try:
         branch = repo.opener('localbranch').read().rstrip('\n')
     except IOError:
         branch = ''
     return encoding.tolocal(branch)
开发者ID:jmurty,项目名称:dotfiles,代码行数:6,代码来源:localbranch.py


示例17: appendValue

def appendValue(doc, node, value):
    textNode = doc.createTextNode(encoding.tolocal(value))
    node.appendChild(textNode)
开发者ID:honsys,项目名称:scm-manager,代码行数:3,代码来源:util.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python extensions.find函数代码示例发布时间:2022-05-27
下一篇:
Python encoding.fromlocal函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap