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


Python PackData.create_index_v2方法代码示例

本文整理汇总了Python中dulwich.pack.PackData.create_index_v2方法的典型用法代码示例。如果您正苦于以下问题:Python PackData.create_index_v2方法的具体用法?Python PackData.create_index_v2怎么用?Python PackData.create_index_v2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dulwich.pack.PackData的用法示例。


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

示例1: move_in_thin_pack

# 需要导入模块: from dulwich.pack import PackData [as 别名]
# 或者: from dulwich.pack.PackData import create_index_v2 [as 别名]
    def move_in_thin_pack(self, path):
        """Move a specific file containing a pack into the pack directory.

        :note: The file should be on the same file system as the 
            packs directory.

        :param path: Path to the pack file.
        """
        data = PackData(path)

        # Write index for the thin pack (do we really need this?)
        temppath = os.path.join(self.pack_dir, 
            sha_to_hex(urllib2.randombytes(20))+".tempidx")
        data.create_index_v2(temppath, self.get_raw)
        p = Pack.from_objects(data, load_pack_index(temppath))

        # Write a full pack version
        temppath = os.path.join(self.pack_dir, 
            sha_to_hex(urllib2.randombytes(20))+".temppack")
        write_pack(temppath, ((o, None) for o in p.iterobjects(self.get_raw)), 
                len(p))
        pack_sha = load_pack_index(temppath+".idx").objects_sha1()
        newbasename = os.path.join(self.pack_dir, "pack-%s" % pack_sha)
        os.rename(temppath+".pack", newbasename+".pack")
        os.rename(temppath+".idx", newbasename+".idx")
        self._add_known_pack(newbasename)
开发者ID:asenchi,项目名称:dulwich,代码行数:28,代码来源:object_store.py

示例2: fetch_objects

# 需要导入模块: from dulwich.pack import PackData [as 别名]
# 或者: from dulwich.pack.PackData import create_index_v2 [as 别名]
 def fetch_objects(self, determine_wants, graph_walker, progress=None):
     fd, path = tempfile.mkstemp(suffix=".pack")
     self.fetch_pack(determine_wants, graph_walker, lambda x: os.write(fd, x), progress)
     os.close(fd)
     basename = path[:-len(".pack")]
     p = PackData(path)
     p.create_index_v2(basename+".idx")
     pack = Pack(basename)
     os.remove(path)
     return (len(p), pack.iterobjects())
开发者ID:harsh-a1,项目名称:repeater-testing,代码行数:12,代码来源:remote.py


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