@contextmanager
def zip_folder(folder_path):
 filename = os.path.join(tempfile.gettempdir(), ('data-' + uuid.uuid4().hex))
 zipfile_name = make_zip(filename, folder_path)
 try:
  (yield zipfile_name)
 finally:
  if os.path.exists(zipfile_name):
   os.remove(zipfile_name)

@ contextmanager def zip_folder ( folder_path ) : filename = os . path . join ( tempfile . gettempdir ( ) , ( 'data-' + uuid . uuid4 ( ) . hex ) ) zipfile_name = make_zip ( filename , folder_path ) try : ( yield zipfile_name ) finally : if os . path . exists ( zipfile_name ) : os . remove ( zipfile_name )
zip the entire folder and return a file to the zip .