本文整理汇总了Python中dulwich.objects.ShaFile.from_raw_chunks方法的典型用法代码示例。如果您正苦于以下问题:Python ShaFile.from_raw_chunks方法的具体用法?Python ShaFile.from_raw_chunks怎么用?Python ShaFile.from_raw_chunks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dulwich.objects.ShaFile
的用法示例。
在下文中一共展示了ShaFile.from_raw_chunks方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: iterobjects
# 需要导入模块: from dulwich.objects import ShaFile [as 别名]
# 或者: from dulwich.objects.ShaFile import from_raw_chunks [as 别名]
def iterobjects(self, get_raw=None):
"""Iterate over the objects in this pack."""
if get_raw is None:
get_raw = self.get_raw
for offset, type, obj, crc32 in self.data.iterobjects():
assert isinstance(offset, int)
type, obj = self.data.resolve_object(offset, type, obj, get_raw)
yield ShaFile.from_raw_chunks(type, obj)
示例2: iterentries
# 需要导入模块: from dulwich.objects import ShaFile [as 别名]
# 或者: from dulwich.objects.ShaFile import from_raw_chunks [as 别名]
def iterentries(self, ext_resolve_ref=None, progress=None):
"""Yield entries summarizing the contents of this pack.
:param ext_resolve_ref: Optional function to resolve base
objects (in case this is a thin pack)
:param progress: Progress function, called with current and
total object count.
This will yield tuples with (sha, offset, crc32)
"""
found = {}
postponed = defaultdict(list)
class Postpone(Exception):
"""Raised to postpone delta resolving."""
def get_ref_text(sha):
assert len(sha) == 20
if sha in found:
return self.get_object_at(found[sha])
if ext_resolve_ref:
try:
return ext_resolve_ref(sha)
except KeyError:
pass
raise Postpone, (sha, )
extra = []
todo = chain(self.iterobjects(progress=progress), extra)
for (offset, type, obj, crc32) in todo:
assert isinstance(offset, int)
assert isinstance(type, int)
try:
type, obj = self.resolve_object(offset, type, obj,
get_ref_text)
except Postpone, (sha, ):
postponed[sha].append((offset, type, obj))
else:
shafile = ShaFile.from_raw_chunks(type, obj)
sha = shafile.sha().digest()
found[sha] = offset
yield sha, offset, crc32
extra.extend(postponed.get(sha, []))
示例3: _do_test_count_blocks_chunks
# 需要导入模块: from dulwich.objects import ShaFile [as 别名]
# 或者: from dulwich.objects.ShaFile import from_raw_chunks [as 别名]
def _do_test_count_blocks_chunks(self, count_blocks):
blob = ShaFile.from_raw_chunks(Blob.type_num, ['a\nb', '\na\n'])
self.assertEqual({hash('a\n'): 4, hash('b\n'): 2}, _count_blocks(blob))
示例4: _do_test_count_blocks_chunks
# 需要导入模块: from dulwich.objects import ShaFile [as 别名]
# 或者: from dulwich.objects.ShaFile import from_raw_chunks [as 别名]
def _do_test_count_blocks_chunks(self, count_blocks):
blob = ShaFile.from_raw_chunks(Blob.type_num, [b"a\nb", b"\na\n"])
self.assertEqual({hash("a\n"): 4, hash("b\n"): 2}, count_blocks(blob))
示例5: iterobjects
# 需要导入模块: from dulwich.objects import ShaFile [as 别名]
# 或者: from dulwich.objects.ShaFile import from_raw_chunks [as 别名]
def iterobjects(self):
"""Iterate over the objects in this pack."""
for offset, type, obj, crc32 in self.data.iterobjects():
assert isinstance(offset, int)
yield ShaFile.from_raw_chunks(
*self.data.resolve_object(offset, type, obj))
示例6: _do_test_count_blocks_chunks
# 需要导入模块: from dulwich.objects import ShaFile [as 别名]
# 或者: from dulwich.objects.ShaFile import from_raw_chunks [as 别名]
def _do_test_count_blocks_chunks(self, count_blocks):
blob = ShaFile.from_raw_chunks(Blob.type_num, [b'a\nb', b'\na\n'])
self.assertBlockCountEqual({b'a\n': 4, b'b\n': 2}, _count_blocks(blob))