当前位置: 首页>>代码示例>>Python>>正文


Python pack.PackStreamReader类代码示例

本文整理汇总了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)
开发者ID:sid0,项目名称:dulwich,代码行数:27,代码来源:test_pack.py

示例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())))
开发者ID:sid0,项目名称:dulwich,代码行数:8,代码来源:test_pack.py

示例3: test_read_objects_empty

 def test_read_objects_empty(self):
     reader = PackStreamReader(BytesIO().read)
     self.assertEqual([], list(reader.read_objects()))
开发者ID:sid0,项目名称:dulwich,代码行数:3,代码来源:test_pack.py

示例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())))
开发者ID:sid0,项目名称:dulwich,代码行数:5,代码来源:test_pack.py


注:本文中的dulwich.pack.PackStreamReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。