def write_to_archive(archive, project_name, files):
"""Write files to the project_name folder of the archive."""
tstamp = datetime.now().timetuple()[:6]
for filepath, contents in files:
if filepath is None or contents in (None, 'null'):
log.debug('Skipping file "%s" with contents "%r"', filepath,
contents)
continue
filepath = join(project_name, filepath)
fileinfo = zipfile.ZipInfo(filepath, tstamp)
fileinfo.external_attr = 0o666 << 16
archive.writestr(fileinfo, contents, zipfile.ZIP_DEFLATED)
评论列表
文章目录