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


Python PackData.get_stored_checksum方法代码示例

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


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

示例1: upload_pack_file

# 需要导入模块: from dulwich.pack import PackData [as 别名]
# 或者: from dulwich.pack.PackData import get_stored_checksum [as 别名]
	def upload_pack_file(self, path):
		p = PackData(path)
		entries = p.sorted_entries()

		# get the sha1 of the pack, same method as dulwich's move_in_pack()
		pack_sha = iter_sha1(e[0] for e in entries)
		key_prefix = calc_pack_prefix(self.prefix, pack_sha)
		pack_key_name = '%s.pack' % key_prefix

		# FIXME: LOCK HERE? Possibly different pack files could
		#        have the same shas, depending on compression?

		log.debug('Uploading %s to %s' % (path, pack_key_name))

		pack_key = self.bucket.new_key(pack_key_name)
		pack_key.set_contents_from_filename(path)
		index_key_name = '%s.idx' % key_prefix

		index_key = self.bucket.new_key(index_key_name)

		index_fd, index_path = tempfile.mkstemp(suffix = '.idx')
		try:
			f = os.fdopen(index_fd, 'wb')
			write_pack_index_v2(f, entries, p.get_stored_checksum())
			os.fsync(index_fd)
			f.close()

			log.debug('Uploading %s to %s' % (index_path, index_key_name))
			index_key.set_contents_from_filename(index_path)
		finally:
			os.remove(index_path)

		p.close()

		return self._create_pack(key_prefix)
开发者ID:mbr,项目名称:amazing-git,代码行数:37,代码来源:dulwich_s3.py

示例2: move_in_pack

# 需要导入模块: from dulwich.pack import PackData [as 别名]
# 或者: from dulwich.pack.PackData import get_stored_checksum [as 别名]
    def move_in_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.
        """
        p = PackData(path)
        entries = p.sorted_entries()
        basename = os.path.join(self.pack_dir, 
            "pack-%s" % iter_sha1(entry[0] for entry in entries))
        write_pack_index_v2(basename+".idx", entries, p.get_stored_checksum())
        os.rename(path, basename + ".pack")
        self._add_known_pack(basename)
开发者ID:RemyStranger,项目名称:agitmemnon-server,代码行数:17,代码来源:object_store.py

示例3: commit

# 需要导入模块: from dulwich.pack import PackData [as 别名]
# 或者: from dulwich.pack.PackData import get_stored_checksum [as 别名]
 def commit():
     f.seek(0)
     pack = PackData(file=f, filename="")
     entries = pack.sorted_entries()
     if len(entries):
         basename = posixpath.join(self.pack_dir,
                                   "pack-%s" %
                                   iter_sha1(entry[0] for
                                             entry in entries))
         index = BytesIO()
         write_pack_index_v2(index, entries, pack.get_stored_checksum())
         self.scon.put_object(basename + ".pack", f)
         f.close()
         self.scon.put_object(basename + ".idx", index)
         index.close()
         final_pack = SwiftPack(basename, scon=self.scon)
         final_pack.check_length_and_checksum()
         self._add_known_pack(basename, final_pack)
         return final_pack
     else:
         return None
开发者ID:PKRoma,项目名称:dulwich,代码行数:23,代码来源:swift.py


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