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


Python objects.ShaFile类代码示例

本文整理汇总了Python中dulwich.objects.ShaFile的典型用法代码示例。如果您正苦于以下问题:Python ShaFile类的具体用法?Python ShaFile怎么用?Python ShaFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ShaFile类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_deflated_smaller_window_buffer

 def test_deflated_smaller_window_buffer(self):
     # zlib on some systems uses smaller buffers,
     # resulting in a different header.
     # See https://github.com/libgit2/libgit2/pull/464
     sf = ShaFile.from_file(BytesIO(small_buffer_zlib_object))
     self.assertEqual(sf.type_name, b'tag')
     self.assertEqual(sf.tagger, b' <@localhost>')
开发者ID:durin42,项目名称:dulwich,代码行数:7,代码来源:test_objects.py

示例2: _get_loose_object

 def _get_loose_object(self, sha):
     path = self._get_shafile_path(sha)
     try:
         return ShaFile.from_path(path)
     except (OSError, IOError), e:
         if e.errno == errno.ENOENT:
             return None
         raise
开发者ID:BrenBarn,项目名称:dreampie,代码行数:8,代码来源:object_store.py

示例3: iterobjects

 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)
         yield ShaFile.from_raw_string(
                 *self.data.resolve_object(offset, type, obj, get_raw))
开发者ID:abderrahim,项目名称:dulwich,代码行数:8,代码来源:pack.py

示例4: iterentries

    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)
            assert isinstance(obj, tuple) or isinstance(obj, str)
            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_string(type, obj)
                sha = shafile.sha().digest()
                found[sha] = offset
                yield sha, offset, crc32
                extra.extend(postponed.get(sha, []))
开发者ID:abderrahim,项目名称:dulwich,代码行数:41,代码来源:pack.py

示例5: __getitem__

 def __getitem__(self, sha):
     """Obtain an object by SHA1."""
     type_num, uncomp = self.get_raw(sha)
     return ShaFile.from_raw_string(type_num, uncomp)
开发者ID:BrenBarn,项目名称:dreampie,代码行数:4,代码来源:object_store.py

示例6: _do_test_count_blocks_chunks

 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))
开发者ID:AaronO,项目名称:dulwich,代码行数:3,代码来源:test_diff_tree.py

示例7: _get_shafile

 def _get_shafile(self, sha):
     path = self._get_shafile_path(sha)
     if os.path.exists(path):
       return ShaFile.from_file(path)
     return None
开发者ID:asenchi,项目名称:dulwich,代码行数:5,代码来源:object_store.py

示例8: __getitem__

 def __getitem__(self, sha1):
     """Retrieve the specified SHA1."""
     type, uncomp = self.get_raw(sha1)
     return ShaFile.from_raw_string(type, uncomp)
开发者ID:abderrahim,项目名称:dulwich,代码行数:4,代码来源:pack.py

示例9: _do_test_count_blocks_chunks

 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))
开发者ID:eberle1080,项目名称:dulwich-py3k,代码行数:3,代码来源:test_diff_tree.py

示例10: iterobjects

 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))
开发者ID:Lutger,项目名称:fuzzballflux,代码行数:6,代码来源:pack.py

示例11: store

 def store(self, istream):
     obj = ShaFile.from_raw_string(type_to_type_id_map[istream.type], istream.read())
     self._dw_repo.object_store.add_object(obj)
     istream.binsha = obj.sha().digest()
     return istream
开发者ID:Gu5HC,项目名称:GitPython,代码行数:5,代码来源:complex.py

示例12: _do_test_count_blocks_chunks

 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))
开发者ID:jelmer,项目名称:dulwich,代码行数:3,代码来源:test_diff_tree.py


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