53 zip_file = zipfile.ZipFile(args.output, 'w', zipfile.ZIP_DEFLATED)
54 if args.source_file:
55 with open(args.source_file) as source_file:
56 file_dict_list = json.load(source_file)
57 for file_dict in file_dict_list:
58 if os.path.islink(file_dict['source']):
59 add_symlink(zip_file, file_dict[
'source'], file_dict[
'destination'])
60 continue
61 if os.path.isdir(file_dict['source']):
62 _zip_dir(file_dict['source'], zip_file, file_dict['destination'])
63 else:
64 zip_file.write(file_dict['source'], file_dict['destination'])
65 else:
66 for path, archive_name in args.input_pairs:
67 if os.path.islink(path):
69 continue
70 if os.path.isdir(path):
71 _zip_dir(path, zip_file, archive_name)
72 else:
73 zip_file.write(path, archive_name)
74 zip_file.close()
75
76