2 """Zip (zip -r9) with encoded filenames
4 Written by Oleg Broytman. Copyright (C) 2009, 2010 PhiloSoft Design.
8 from getopt import getopt, GetoptError
9 from zipfile import ZipFile, ZIP_DEFLATED
10 from m_lib.defenc import default_encoding
13 sys.exit('Usage: %s file.zip file1 dir2...' % sys.argv[0])
16 options, arguments = getopt(sys.argv[1:], '')
20 if len(arguments) < 2:
23 def addToZip(zf, path):
24 if os.path.isfile(path):
26 recoded_path = path.decode(default_encoding).encode('cp866')
27 zf.write(path, recoded_path, ZIP_DEFLATED)
28 elif os.path.isdir(path):
29 for nm in os.listdir(path):
30 addToZip(zf, os.path.join(path, nm))
34 if os.path.splitext(zname)[1] not in ('.zip', '.ZIP'):
37 zf = ZipFile(zname, 'w', allowZip64=True)
39 for path in arguments[1:]: