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


Python PackStreamReader.read_objects方法代码示例

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

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

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

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


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