import sys, os, time
from getopt import getopt, GetoptError
+from shutil import copyfileobj
from zipfile import ZipFile
from m_lib.defenc import default_encoding
sys.exit('Usage: %s file.zip' % sys.argv[0])
try:
- options, arguments = getopt(sys.argv[1:], '')
+ options, arguments = getopt(sys.argv[1:], '')
except GetoptError:
usage()
-if len(arguments) <> 1:
+if len(arguments) != 1:
usage()
zf = ZipFile(arguments[0], 'r')
os.makedirs(tgtdir)
if not tgt.endswith('/'):
+ infile = zf.open(zinfo.filename)
fp = open(tgt, 'wb')
- fp.write(zf.read(zinfo.filename))
+ copyfileobj(infile, fp)
fp.close()
+ infile.close()
dt = time.mktime(zinfo.date_time + (0, 0, -1))
os.utime(tgt, (dt, dt))
zf.close()