本文整理汇总了Python中dulwich.pack.PackStreamReader.read_objects方法的典型用法代码示例。如果您正苦于以下问题:Python PackStreamReader.read_objects方法的具体用法?Python PackStreamReader.read_objects怎么用?Python PackStreamReader.read_objects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dulwich.pack.PackStreamReader
的用法示例。
在下文中一共展示了PackStreamReader.read_objects方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_read_objects
# 需要导入模块: from dulwich.pack import PackStreamReader [as 别名]
# 或者: from dulwich.pack.PackStreamReader import read_objects [as 别名]
def test_read_objects(self):
f = BytesIO()
entries = build_pack(f, [
(Blob.type_num, 'blob'),
(OFS_DELTA, (0, 'blob1')),
])
reader = PackStreamReader(f.read)
objects = list(reader.read_objects(compute_crc32=True))
self.assertEqual(2, len(objects))
unpacked_blob, unpacked_delta = objects
self.assertEqual(entries[0][0], unpacked_blob.offset)
self.assertEqual(Blob.type_num, unpacked_blob.pack_type_num)
self.assertEqual(Blob.type_num, unpacked_blob.obj_type_num)
self.assertEqual(None, unpacked_blob.delta_base)
self.assertEqual('blob', ''.join(unpacked_blob.decomp_chunks))
self.assertEqual(entries[0][4], unpacked_blob.crc32)
self.assertEqual(entries[1][0], unpacked_delta.offset)
self.assertEqual(OFS_DELTA, unpacked_delta.pack_type_num)
self.assertEqual(None, unpacked_delta.obj_type_num)
self.assertEqual(unpacked_delta.offset - unpacked_blob.offset,
unpacked_delta.delta_base)
delta = create_delta('blob', 'blob1')
self.assertEqual(delta, ''.join(unpacked_delta.decomp_chunks))
self.assertEqual(entries[1][4], unpacked_delta.crc32)
示例2: test_read_objects_buffered
# 需要导入模块: from dulwich.pack import PackStreamReader [as 别名]
# 或者: from dulwich.pack.PackStreamReader import read_objects [as 别名]
def test_read_objects_buffered(self):
f = BytesIO()
build_pack(f, [
(Blob.type_num, 'blob'),
(OFS_DELTA, (0, 'blob1')),
])
reader = PackStreamReader(f.read, zlib_bufsize=4)
self.assertEqual(2, len(list(reader.read_objects())))
示例3: test_read_objects_empty
# 需要导入模块: from dulwich.pack import PackStreamReader [as 别名]
# 或者: from dulwich.pack.PackStreamReader import read_objects [as 别名]
def test_read_objects_empty(self):
reader = PackStreamReader(BytesIO().read)
self.assertEqual([], list(reader.read_objects()))
示例4: test_read_objects_emtpy
# 需要导入模块: from dulwich.pack import PackStreamReader [as 别名]
# 或者: from dulwich.pack.PackStreamReader import read_objects [as 别名]
def test_read_objects_emtpy(self):
f = BytesIO()
build_pack(f, [])
reader = PackStreamReader(f.read)
self.assertEqual(0, len(list(reader.read_objects())))