def restoreConfigZip(archive, targetDir):
 try:
  if (not ek(os.path.exists, targetDir)):
   ek(os.mkdir, targetDir)
  else:
   def path_leaf(path):
    (head, tail) = ek(os.path.split, path)
    return (tail or ek(os.path.basename, head))
   bakFilename = u'{0}-{1}'.format(path_leaf(targetDir), datetime.datetime.now().strftime(u'%Y%m%d_%H%M%S'))
   shutil.move(targetDir, ek(os.path.join, ek(os.path.dirname, targetDir), bakFilename))
  zip_file = zipfile.ZipFile(archive, u'r', allowZip64=True)
  for member in zip_file.namelist():
   zip_file.extract(member, targetDir)
  zip_file.close()
  return True
 except Exception as error:
  logger.log(u'Zip extraction error: {0}'.format(error), logger.ERROR)
  shutil.rmtree(targetDir)
  return False

def restoreConfigZip ( archive , targetDir ) : try : if ( not ek ( os . path . exists , targetDir ) ) : ek ( os . mkdir , targetDir ) else : def path_leaf ( path ) : ( head , tail ) = ek ( os . path . split , path ) return ( tail or ek ( os . path . basename , head ) ) bakFilename = u'{0}-{1}' . format ( path_leaf ( targetDir ) , datetime . datetime . now ( ) . strftime ( u'%Y%m%d_%H%M%S' ) ) shutil . move ( targetDir , ek ( os . path . join , ek ( os . path . dirname , targetDir ) , bakFilename ) ) zip_file = zipfile . ZipFile ( archive , u'r' , allowZip64 = True ) for member in zip_file . namelist ( ) : zip_file . extract ( member , targetDir ) zip_file . close ( ) return True except Exception as error : logger . log ( u'Zip extraction error: {0}' . format ( error ) , logger . ERROR ) shutil . rmtree ( targetDir ) return False
restores a config zip file back in place .