本文整理匯總了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()