本文整理汇总了Python中dulwich.pack.PackStreamReader类的典型用法代码示例。如果您正苦于以下问题:Python PackStreamReader类的具体用法?Python PackStreamReader怎么用?Python PackStreamReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PackStreamReader类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_read_objects
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
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
def test_read_objects_empty(self):
reader = PackStreamReader(BytesIO().read)
self.assertEqual([], list(reader.read_objects()))
示例4: test_read_objects_emtpy
def test_read_objects_emtpy(self):
f = BytesIO()
build_pack(f, [])
reader = PackStreamReader(f.read)
self.assertEqual(0, len(list(reader.read_objects())))