@contextmanager
def open_zip(path_or_file, *args, **kwargs):
 try:
  allowZip64 = kwargs.pop(u'allowZip64', True)
  zf = zipfile.ZipFile(path_or_file, allowZip64=allowZip64, *args, **kwargs)
 except zipfile.BadZipfile as bze:
  raise zipfile.BadZipfile(u'Bad Zipfile {0}: {1}'.format(path_or_file, bze))
 try:
  (yield zf)
 finally:
  zf.close()

@ contextmanager def open_zip ( path_or_file , * args , ** kwargs ) : try : allowZip64 = kwargs . pop ( u'allowZip64' , True ) zf = zipfile . ZipFile ( path_or_file , allowZip64 = allowZip64 , * args , ** kwargs ) except zipfile . BadZipfile as bze : raise zipfile . BadZipfile ( u'Bad Zipfile {0}: {1}' . format ( path_or_file , bze ) ) try : ( yield zf ) finally : zf . close ( )
a with-context for zip files .