本文整理汇总了Python中dulwich.pack.Pack._data_load方法的典型用法代码示例。如果您正苦于以下问题:Python Pack._data_load方法的具体用法?Python Pack._data_load怎么用?Python Pack._data_load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dulwich.pack.Pack
的用法示例。
在下文中一共展示了Pack._data_load方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_pack
# 需要导入模块: from dulwich.pack import Pack [as 别名]
# 或者: from dulwich.pack.Pack import _data_load [as 别名]
def _create_pack(self, path):
def data_loader():
# read and writable temporary file
pack_tmpfile = tempfile.NamedTemporaryFile()
# download into temporary file
log.debug('Downloading pack %s into %s' % (path, pack_tmpfile))
pack_key = self.bucket.new_key('%s.pack' % path)
# store
pack_key.get_contents_to_file(pack_tmpfile)
log.debug('Filesize is %d' % pack_key.size)
log.debug('Rewinding...')
pack_tmpfile.flush()
pack_tmpfile.seek(0)
return PackData.from_file(pack_tmpfile, pack_key.size)
def idx_loader():
index_tmpfile = tempfile.NamedTemporaryFile()
log.debug('Downloading pack index %s into %s' % (path, index_tmpfile))
index_key = self.bucket.new_key('%s.idx' % path)
index_key.get_contents_to_file(index_tmpfile)
log.debug('Rewinding...')
index_tmpfile.flush()
index_tmpfile.seek(0)
return load_pack_index_file(index_tmpfile.name, index_tmpfile)
p = Pack(path)
p._data_load = data_loader
p._idx_load = idx_loader
return p