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

Python node.bin函数代码示例

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

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



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

示例1: parse_manifest

def parse_manifest(mfdict, fdict, lines):
    for l in lines.splitlines():
        f, n = l.split("\0")
        if len(n) > 40:
            fdict[f] = n[40:]
            mfdict[f] = bin(n[:40])
        else:
            mfdict[f] = bin(n)
开发者ID:dkrisman,项目名称:Traipse,代码行数:8,代码来源:parsers.py


示例2: parse

 def parse(self, lines):
     mfdict = manifestdict()
     fdict = mfdict._flags
     for l in lines.splitlines():
         f, n = l.split('\0')
         if len(n) > 40:
             fdict[f] = n[40:]
             mfdict[f] = bin(n[:40])
         else:
             mfdict[f] = bin(n)
     return mfdict
开发者ID:c0ns0le,项目名称:cygwin,代码行数:11,代码来源:manifest.py


示例3: do_changegroupsubset

    def do_changegroupsubset(self):
        argmap = dict([self.getarg(), self.getarg()])
        bases = [bin(n) for n in argmap['bases'].split(' ')]
        heads = [bin(n) for n in argmap['heads'].split(' ')]

        cg = self.repo.changegroupsubset(bases, heads, 'serve')
        while True:
            d = cg.read(4096)
            if not d:
                break
            self.fout.write(d)

        self.fout.flush()
开发者ID:dkrisman,项目名称:Traipse,代码行数:13,代码来源:sshserver.py


示例4: diff

 def diff(self, diffopts, node2, match, prefix, **opts):
     try:
         node1 = node.bin(self._state[1])
         # We currently expect node2 to come from substate and be
         # in hex format
         if node2 is not None:
             node2 = node.bin(node2)
         cmdutil.diffordiffstat(self._repo.ui, self._repo, diffopts,
                                node1, node2, match,
                                prefix=os.path.join(prefix, self._path),
                                listsubrepos=True, **opts)
     except error.RepoLookupError, inst:
         self._repo.ui.warn(_('warning: error "%s" in subrepository "%s"\n')
                            % (inst, subrelpath(self)))
开发者ID:helloandre,项目名称:cr48,代码行数:14,代码来源:subrepo.py


示例5: _partialmatch

    def _partialmatch(self, id):
        try:
            return self.index.partialmatch(id)
        except RevlogError:
            # parsers.c radix tree lookup gave multiple matches
            raise LookupError(id, self.indexfile, _("ambiguous identifier"))
        except (AttributeError, ValueError):
            # we are pure python, or key was too short to search radix tree
            pass

        if id in self._pcache:
            return self._pcache[id]

        if len(id) < 40:
            try:
                # hex(node)[:...]
                l = len(id) // 2  # grab an even number of digits
                prefix = bin(id[:l * 2])
                nl = [e[7] for e in self.index if e[7].startswith(prefix)]
                nl = [n for n in nl if hex(n).startswith(id)]
                if len(nl) > 0:
                    if len(nl) == 1:
                        self._pcache[id] = nl[0]
                        return nl[0]
                    raise LookupError(id, self.indexfile,
                                      _('ambiguous identifier'))
                return None
            except TypeError:
                pass
开发者ID:chuchiperriman,项目名称:hg-stable,代码行数:29,代码来源:revlog.py


示例6: lookup

 def lookup(self, key):
     self.requirecap("lookup", _("look up remote revision"))
     d = self._call("lookup", key=key)
     success, data = d[:-1].split(" ", 1)
     if int(success):
         return bin(data)
     self._abort(error.RepoError(data))
开发者ID:helloandre,项目名称:cr48,代码行数:7,代码来源:wireproto.py


示例7: lookup

 def lookup(self, key):
     self.requirecap('lookup', _('look up remote revision'))
     d = self._call("lookup", key=encoding.fromlocal(key))
     success, data = d[:-1].split(" ", 1)
     if int(success):
         return bin(data)
     self._abort(error.RepoError(data))
开发者ID:MezzLabs,项目名称:mercurial,代码行数:7,代码来源:wireproto.py


示例8: renamed

 def renamed(self, node):
     if self.parents(node)[0] != nullid:
         return False
     m = self._readmeta(node)
     if m and "copy" in m:
         return (m["copy"], bin(m["copyrev"]))
     return False
开发者ID:c0ns0le,项目名称:cygwin,代码行数:7,代码来源:filelog.py


示例9: lookup

 def lookup(self, key):
     self.requirecap('lookup', _('look up remote revision'))
     d = self.do_cmd("lookup", key = key).read()
     success, data = d[:-1].split(' ', 1)
     if int(success):
         return bin(data)
     raise error.RepoError(data)
开发者ID:iluxa-c0m,项目名称:mercurial-crew-tonfa,代码行数:7,代码来源:httprepo.py


示例10: _match

 def _match(self, id):
     if isinstance(id, (long, int)):
         # rev
         return self.node(id)
     if len(id) == 20:
         # possibly a binary node
         # odds of a binary node being all hex in ASCII are 1 in 10**25
         try:
             node = id
             self.rev(node) # quick search the index
             return node
         except LookupError:
             pass # may be partial hex id
     try:
         # str(rev)
         rev = int(id)
         if str(rev) != id:
             raise ValueError
         if rev < 0:
             rev = len(self) + rev
         if rev < 0 or rev >= len(self):
             raise ValueError
         return self.node(rev)
     except (ValueError, OverflowError):
         pass
     if len(id) == 40:
         try:
             # a full hex nodeid?
             node = bin(id)
             self.rev(node)
             return node
         except (TypeError, LookupError):
             pass
开发者ID:mortonfox,项目名称:cr48,代码行数:33,代码来源:revlog.py


示例11: _readroots

def _readroots(repo, phasedefaults=None):
    """Read phase roots from disk

    phasedefaults is a list of fn(repo, roots) callable, which are
    executed if the phase roots file does not exist. When phases are
    being initialized on an existing repository, this could be used to
    set selected changesets phase to something else than public.

    Return (roots, dirty) where dirty is true if roots differ from
    what is being stored.
    """
    repo = repo.unfiltered()
    dirty = False
    roots = [set() for i in allphases]
    try:
        f = repo.sopener("phaseroots")
        try:
            for line in f:
                phase, nh = line.split()
                roots[int(phase)].add(bin(nh))
        finally:
            f.close()
    except IOError, inst:
        if inst.errno != errno.ENOENT:
            raise
        if phasedefaults:
            for f in phasedefaults:
                roots = f(repo, roots)
        dirty = True
开发者ID:ZanderZhang,项目名称:Andriod-Learning,代码行数:29,代码来源:phases.py


示例12: analyzeremotephases

def analyzeremotephases(repo, subset, roots):
    """Compute phases heads and root in a subset of node from root dict

    * subset is heads of the subset
    * roots is {<nodeid> => phase} mapping. key and value are string.

    Accept unknown element input
    """
    repo = repo.unfiltered()
    # build list from dictionary
    draftroots = []
    nodemap = repo.changelog.nodemap  # to filter unknown nodes
    for nhex, phase in roots.iteritems():
        if nhex == "publishing":  # ignore data related to publish option
            continue
        node = bin(nhex)
        phase = int(phase)
        if phase == 0:
            if node != nullid:
                repo.ui.warn(_("ignoring inconsistent public root" " from remote: %s\n") % nhex)
        elif phase == 1:
            if node in nodemap:
                draftroots.append(node)
        else:
            repo.ui.warn(_("ignoring unexpected root from remote: %i %s\n") % (phase, nhex))
    # compute heads
    publicheads = newheads(repo, subset, draftroots)
    return publicheads, draftroots
开发者ID:ZanderZhang,项目名称:Andriod-Learning,代码行数:28,代码来源:phases.py


示例13: lookup

 def lookup(self, key):
     self.requirecap('lookup', _('look up remote revision'))
     d = self.call("lookup", key=key)
     success, data = d[:-1].split(" ", 1)
     if int(success):
         return bin(data)
     else:
         self.raise_(repo.RepoError(data))
开发者ID:c0ns0le,项目名称:cygwin,代码行数:8,代码来源:sshrepo.py


示例14: lookup

 def lookup(self, key):
     self.requirecap("lookup", _("look up remote revision"))
     f = future()
     yield {"key": encoding.fromlocal(key)}, f
     d = f.value
     success, data = d[:-1].split(" ", 1)
     if int(success):
         yield bin(data)
     self._abort(error.RepoError(data))
开发者ID:pierfort123,项目名称:mercurial,代码行数:9,代码来源:wireproto.py


示例15: lookup

 def lookup(self, key):
     self.requirecap('lookup', _('look up remote revision'))
     f = future()
     yield todict(key=encoding.fromlocal(key)), f
     d = f.value
     success, data = d[:-1].split(" ", 1)
     if int(success):
         yield bin(data)
     self._abort(error.RepoError(data))
开发者ID:agbiotec,项目名称:galaxy-tools-vcr,代码行数:9,代码来源:wireproto.py


示例16: read

def read(repo):
    try:
        f = repo.vfs(_filename(repo))
        lines = f.read().split('\n')
        f.close()
    except (IOError, OSError):
        return None

    try:
        cachekey = lines.pop(0).split(" ", 2)
        last, lrev = cachekey[:2]
        last, lrev = bin(last), int(lrev)
        filteredhash = None
        if len(cachekey) > 2:
            filteredhash = bin(cachekey[2])
        partial = branchcache(tipnode=last, tiprev=lrev,
                              filteredhash=filteredhash)
        if not partial.validfor(repo):
            # invalidate the cache
            raise ValueError('tip differs')
        for l in lines:
            if not l:
                continue
            node, state, label = l.split(" ", 2)
            if state not in 'oc':
                raise ValueError('invalid branch state')
            label = encoding.tolocal(label.strip())
            if not node in repo:
                raise ValueError('node %s does not exist' % node)
            node = bin(node)
            partial.setdefault(label, []).append(node)
            if state == 'c':
                partial._closednodes.add(node)
    except KeyboardInterrupt:
        raise
    except Exception as inst:
        if repo.ui.debugflag:
            msg = 'invalid branchheads cache'
            if repo.filtername is not None:
                msg += ' (%s)' % repo.filtername
            msg += ': %s\n'
            repo.ui.debug(msg % inst)
        partial = None
    return partial
开发者ID:pierfort123,项目名称:mercurial,代码行数:44,代码来源:branchmap.py


示例17: _readtaghist

def _readtaghist(ui, repo, lines, fn, recode=None, calcnodelines=False):
    '''Read tag definitions from a file (or any source of lines).

    This function returns two sortdicts with similar information:

    - the first dict, bintaghist, contains the tag information as expected by
      the _readtags function, i.e. a mapping from tag name to (node, hist):
        - node is the node id from the last line read for that name,
        - hist is the list of node ids previously associated with it (in file
          order). All node ids are binary, not hex.

    - the second dict, hextaglines, is a mapping from tag name to a list of
      [hexnode, line number] pairs, ordered from the oldest to the newest node.

    When calcnodelines is False the hextaglines dict is not calculated (an
    empty dict is returned). This is done to improve this function's
    performance in cases where the line numbers are not needed.
    '''

    bintaghist = util.sortdict()
    hextaglines = util.sortdict()
    count = 0

    def warn(msg):
        ui.warn(_("%s, line %s: %s\n") % (fn, count, msg))

    for nline, line in enumerate(lines):
        count += 1
        if not line:
            continue
        try:
            (nodehex, name) = line.split(" ", 1)
        except ValueError:
            warn(_("cannot parse entry"))
            continue
        name = name.strip()
        if recode:
            name = recode(name)
        try:
            nodebin = bin(nodehex)
        except TypeError:
            warn(_("node '%s' is not well formed") % nodehex)
            continue

        # update filetags
        if calcnodelines:
            # map tag name to a list of line numbers
            if name not in hextaglines:
                hextaglines[name] = []
            hextaglines[name].append([nodehex, nline])
            continue
        # map tag name to (node, hist)
        if name not in bintaghist:
            bintaghist[name] = []
        bintaghist[name].append(nodebin)
    return bintaghist, hextaglines
开发者ID:RayFerr000,项目名称:PLTL,代码行数:56,代码来源:tags.py


示例18: _read

    def _read(self):
        """Analyse each record content to restore a serialized state from disk

        This function process "record" entry produced by the de-serialization
        of on disk file.
        """
        self._state = {}
        records = self._readrecords()
        for rtype, record in records:
            if rtype == 'L':
                self._local = bin(record)
            elif rtype == 'O':
                self._other = bin(record)
            elif rtype == "F":
                bits = record.split("\0")
                self._state[bits[0]] = bits[1:]
            elif not rtype.islower():
                raise util.Abort(_('unsupported merge state record: %s')
                                   % rtype)
        self._dirty = False
开发者ID:leetaizhu,项目名称:Odoo_ENV_MAC_OS,代码行数:20,代码来源:merge.py


示例19: branchmap

 def branchmap(self):
     d = self.call("branchmap")
     try:
         branchmap = {}
         for branchpart in d.splitlines():
             branchheads = branchpart.split(' ')
             branchname = urllib.unquote(branchheads[0])
             branchheads = [bin(x) for x in branchheads[1:]]
             branchmap[branchname] = branchheads
         return branchmap
     except:
         raise error.ResponseError(_("unexpected response:"), d)
开发者ID:Nurb432,项目名称:plan9front,代码行数:12,代码来源:sshrepo.py


示例20: find

 def find(self, node, f):
     '''look up entry for a single file efficiently.
     return (node, flags) pair if found, (None, None) if not.'''
     if self.mapcache and node == self.mapcache[0]:
         return self.mapcache[1].get(f), self.mapcache[1].flags(f)
     text = self.revision(node)
     start, end = self._search(text, f)
     if start == end:
         return None, None
     l = text[start:end]
     f, n = l.split('\0')
     return bin(n[:40]), n[40:-1]
开发者ID:c0ns0le,项目名称:cygwin,代码行数:12,代码来源:manifest.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python node.expr_list函数代码示例发布时间:2022-05-27
下一篇:
Python config.ctx_list函数代码示例发布时间: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