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

Python util.filechunkiter函数代码示例

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

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



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

示例1: streamer

    def streamer(repo, entries, total):
        '''stream out all metadata files in repository.'''
        yield '0\n' # success
        repo.ui.debug('%d files, %d bytes to transfer\n' %
                      (len(entries), total_bytes))
        yield '%d %d\n' % (len(entries), total_bytes)

        sopener = repo.sopener
        oldaudit = sopener.mustaudit
        debugflag = repo.ui.debugflag
        sopener.mustaudit = False

        try:
            for name, size in entries:
                if debugflag:
                    repo.ui.debug('sending %s (%d bytes)\n' % (name, size))
                # partially encode name over the wire for backwards compat
                yield '%s\0%d\n' % (store.encodedir(name), size)
                if size <= 65536:
                    fp = sopener(name)
                    try:
                        data = fp.read(size)
                    finally:
                        fp.close()
                    yield data
                else:
                    for chunk in util.filechunkiter(sopener(name), limit=size):
                        yield chunk
        # replace with "finally:" when support for python 2.4 has been dropped
        except Exception:
            sopener.mustaudit = oldaudit
            raise
        sopener.mustaudit = oldaudit
开发者ID:chuchiperriman,项目名称:hg-stable,代码行数:33,代码来源:wireproto.py


示例2: stream_out

def stream_out(repo, untrusted=False):
    '''stream out all metadata files in repository.
    writes to file-like object, must support write() and optional flush().'''

    if not repo.ui.configbool('server', 'uncompressed', untrusted=untrusted):
        raise StreamException(1)

    entries = []
    total_bytes = 0
    try:
        # get consistent snapshot of repo, lock during scan
        lock = repo.lock()
        try:
            repo.ui.debug(_('scanning\n'))
            for name, ename, size in repo.store.walk():
                # for backwards compat, name was partially encoded
                entries.append((store.encodedir(name), size))
                total_bytes += size
        finally:
            lock.release()
    except error.LockError:
        raise StreamException(2)

    yield '0\n'
    repo.ui.debug(_('%d files, %d bytes to transfer\n') %
                  (len(entries), total_bytes))
    yield '%d %d\n' % (len(entries), total_bytes)
    for name, size in entries:
        repo.ui.debug(_('sending %s (%d bytes)\n') % (name, size))
        yield '%s\0%d\n' % (name, size)
        for chunk in util.filechunkiter(repo.sopener(name), limit=size):
            yield chunk
开发者ID:Nurb432,项目名称:plan9front,代码行数:32,代码来源:streamclone.py


示例3: zgenerator

def zgenerator(f):
    zd = zlib.decompressobj()
    try:
        for chunk in util.filechunkiter(f):
            yield zd.decompress(chunk)
    except httplib.HTTPException, inst:
        raise IOError(None, _('connection ended unexpectedly'))
开发者ID:c0ns0le,项目名称:cygwin,代码行数:7,代码来源:httprepo.py


示例4: _sendfile

 def _sendfile(self, data):
     # send a file
     if isinstance(data, httpsendfile):
         # if auth required, some data sent twice, so rewind here
         data.seek(0)
         for chunk in util.filechunkiter(data):
             connection.send(self, chunk)
     else:
         connection.send(self, data)
开发者ID:Frostman,项目名称:intellij-community,代码行数:9,代码来源:url.py


示例5: zgenerator

def zgenerator(f):
    zd = zlib.decompressobj()
    try:
        for chunk in util.filechunkiter(f):
            while chunk:
                yield zd.decompress(chunk, 2**18)
                chunk = zd.unconsumed_tail
    except httplib.HTTPException:
        raise IOError(None, _('connection ended unexpectedly'))
    yield zd.flush()
开发者ID:ThissDJ,项目名称:designhub,代码行数:10,代码来源:httprepo.py


示例6: __init__

    def __init__(self, ui, path, bundlename):
        self._tempparent = None
        try:
            localrepo.localrepository.__init__(self, ui, path)
        except error.RepoError:
            self._tempparent = tempfile.mkdtemp()
            localrepo.instance(ui, self._tempparent, 1)
            localrepo.localrepository.__init__(self, ui, self._tempparent)

        if path:
            self._url = 'bundle:' + path + '+' + bundlename
        else:
            self._url = 'bundle:' + bundlename

        self.tempfile = None
        self.bundlefile = open(bundlename, "rb")
        header = self.bundlefile.read(6)
        if not header.startswith("HG"):
            raise util.Abort(_("%s: not a Mercurial bundle file") % bundlename)
        elif not header.startswith("HG10"):
            raise util.Abort(_("%s: unknown bundle version") % bundlename)
        elif (header == "HG10BZ") or (header == "HG10GZ"):
            fdtemp, temp = tempfile.mkstemp(prefix="hg-bundle-",
                                            suffix=".hg10un", dir=self.path)
            self.tempfile = temp
            fptemp = os.fdopen(fdtemp, 'wb')
            def generator(f):
                if header == "HG10BZ":
                    zd = bz2.BZ2Decompressor()
                    zd.decompress("BZ")
                elif header == "HG10GZ":
                    zd = zlib.decompressobj()
                for chunk in f:
                    yield zd.decompress(chunk)
            gen = generator(util.filechunkiter(self.bundlefile, 4096))

            try:
                fptemp.write("HG10UN")
                for chunk in gen:
                    fptemp.write(chunk)
            finally:
                fptemp.close()
                self.bundlefile.close()

            self.bundlefile = open(self.tempfile, "rb")
            # seek right after the header
            self.bundlefile.seek(6)
        elif header == "HG10UN":
            # nothing to do
            pass
        else:
            raise util.Abort(_("%s: unknown bundle compression type")
                             % bundlename)
        # dict with the mapping 'filename' -> position in the bundle
        self.bundlefilespos = {}
开发者ID:iluxa-c0m,项目名称:mercurial-crew-tonfa,代码行数:55,代码来源:bundlerepo.py


示例7: streamer

 def streamer(repo, entries, total):
     """stream out all metadata files in repository."""
     yield "0\n"  # success
     repo.ui.debug("%d files, %d bytes to transfer\n" % (len(entries), total_bytes))
     yield "%d %d\n" % (len(entries), total_bytes)
     for name, size in entries:
         repo.ui.debug("sending %s (%d bytes)\n" % (name, size))
         # partially encode name over the wire for backwards compat
         yield "%s\0%d\n" % (store.encodedir(name), size)
         for chunk in util.filechunkiter(repo.sopener(name), limit=size):
             yield chunk
开发者ID:helloandre,项目名称:cr48,代码行数:11,代码来源:wireproto.py


示例8: generator

 def generator(f):
     zd = bz2.BZ2Decompressor()
     zd.decompress("BZ")
     for chunk in util.filechunkiter(f, 4096):
         yield zd.decompress(chunk)
开发者ID:dkrisman,项目名称:Traipse,代码行数:5,代码来源:changegroup.py


示例9: generator

 def generator(f):
     zd = zlib.decompressobj()
     for chunk in util.filechunkiter(f):
         yield zd.decompress(chunk)
开发者ID:jordigh,项目名称:mercurial-crew,代码行数:4,代码来源:changegroup.py


示例10: except

    repolock = None
    try:
        try:
            repolock = repo.lock()
        except (lock.LockHeld, lock.LockUnavailable), inst:
            repo.ui.warn('locking the repository failed: %s\n' % (inst,))
            fileobj.write('2\n')
            return

        fileobj.write('0\n')
        repo.ui.debug('scanning\n')
        entries = []
        total_bytes = 0
        for name, size in walkrepo(repo.spath):
            name = repo.decodefn(util.pconvert(name))
            entries.append((name, size))
            total_bytes += size
    finally:
        del repolock

    repo.ui.debug('%d files, %d bytes to transfer\n' %
                  (len(entries), total_bytes))
    fileobj.write('%d %d\n' % (len(entries), total_bytes))
    for name, size in entries:
        repo.ui.debug('sending %s (%d bytes)\n' % (name, size))
        fileobj.write('%s\0%d\n' % (name, size))
        for chunk in util.filechunkiter(repo.sopener(name), limit=size):
            fileobj.write(chunk)
    flush = getattr(fileobj, 'flush', None)
    if flush: flush()
开发者ID:c0ns0le,项目名称:cygwin,代码行数:30,代码来源:streamclone.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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