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


Python Index.write方法代码示例

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


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

示例1:

# 需要导入模块: from index import Index [as 别名]
# 或者: from index.Index import write [as 别名]
# Copy needed files
file_count = 0
for file, md5 in index.path_to_md5.items():
	if md5 not in index.md5_to_archive:
		file_count = file_count + 1
		
		# Record that this hash is in this archive
		index.md5_to_archive[md5] = archive_name
		
		# Copy the file
		dir = os.path.join(staging_dir, md5[0:2], md5[2:4])
		if not os.path.isdir(dir):
			os.makedirs(dir)
		shutil.copyfile(os.path.join(source_dir, file), os.path.join(dir, md5))
index.write(os.path.join(staging_dir, '%s.backrypt' % now_string))

if file_count == 0:
	shutil.rmtree(temp_dir)
	print('No new or modified files to backup since last backup')
	sys.exit(0)

# Tar up staging_dir to os.path.join(temp_dir, tgz_name)
tar_path = os.path.join(temp_dir, tar_name)
tar = tarfile.open(tar_path, 'w:bz2')
tar.add(staging_dir, arcname='staging')
tar.close()

# Encrypt tgz to os.path.join(temp_dir, archive_name)
archive_path = os.path.join(temp_dir, archive_name)
key = aestool.get_key(password)
开发者ID:stevearm,项目名称:backrypt,代码行数:32,代码来源:backrypt.py


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