本文整理汇总了Python中dulwich.pack.PackStreamCopier类的典型用法代码示例。如果您正苦于以下问题:Python PackStreamCopier类的具体用法?Python PackStreamCopier怎么用?Python PackStreamCopier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PackStreamCopier类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_thin_pack
def add_thin_pack(self, read_all, read_some):
"""Add a new thin pack to this object store.
Thin packs are packs that contain deltas with parents that exist outside
the pack. They should never be placed in the object store directly, and
always indexed and completed as they are copied.
:param read_all: Read function that blocks until the number of requested
bytes are read.
:param read_some: Read function that returns at least one byte, but may
not return the number of bytes requested.
:return: A Pack object pointing at the now-completed thin pack in the
objects/pack directory.
"""
fd, path = tempfile.mkstemp(dir=self.path, prefix='tmp_pack_')
f = os.fdopen(fd, 'w+b')
try:
indexer = PackIndexer(f, resolve_ext_ref=self.get_raw)
copier = PackStreamCopier(read_all, read_some, f,
delta_iter=indexer)
copier.verify()
return self._complete_thin_pack(f, path, copier, indexer)
finally:
f.close()
示例2: add_thin_pack
def add_thin_pack(self, read_all, read_some):
f = StringIO()
indexer = PackIndexer(f, resolve_ext_ref=self.get_raw)
copier = PackStreamCopier(read_all, read_some, f, delta_iter=indexer)
copier.verify()
pack_store = PackStore(repository=self.REPO)
final_pack = Pack.from_thinpack(pack_store, f, indexer, resolve_ext_ref=self.get_raw)
self._add_known_pack(final_pack)
示例3: add_thin_pack
def add_thin_pack(self, read_all, read_some):
"""Read a thin pack
Read it from a stream and complete it in a temporary file.
Then the pack and the corresponding index file are uploaded to Swift.
"""
fd, path = tempfile.mkstemp(prefix='tmp_pack_')
f = os.fdopen(fd, 'w+b')
try:
indexer = PackIndexer(f, resolve_ext_ref=self.get_raw)
copier = PackStreamCopier(read_all, read_some, f,
delta_iter=indexer)
copier.verify()
return self._complete_thin_pack(f, path, copier, indexer)
finally:
f.close()
os.unlink(path)
示例4: add_thin_pack
def add_thin_pack(self, read_all, read_some):
"""Add a new thin pack to this object store.
Thin packs are packs that contain deltas with parents that exist outside
the pack. Because this object store doesn't support packs, we extract
and add the individual objects.
:param read_all: Read function that blocks until the number of requested
bytes are read.
:param read_some: Read function that returns at least one byte, but may
not return the number of bytes requested.
"""
f, commit = self.add_pack()
indexer = PackIndexer(f, resolve_ext_ref=self.get_raw)
copier = PackStreamCopier(read_all, read_some, f, delta_iter=indexer)
copier.verify()
self._complete_thin_pack(f, indexer)
commit()