code: def unzip_file(filename, location, flatten=True):
      # type: (str, str, bool) -> None
      
      ensure_dir(location)
      zipfp = open(filename, 'rb')
      try:
          zip = zipfile.ZipFile(zipfp, allowZip64=True)
          leading = has_leading_dir(zip.namelist()) and flatten
          for info in zip.infolist():
              name = info.filename
              fn = name
              if leading:
                  fn = split_leading_dir(name)[1]
              fn = os.path.join(location, fn)
              dir = os.path.dirname(fn)
              if fn.endswith('/') or fn.endswith('\\'):
                  # A directory
                  ensure_dir(fn)
              else:
                  ensure_dir(dir)
                  # Don't use read() to avoid allocating an arbitrarily large
                  # chunk of memory for the file's content
                  fp = zip.open(name)
                  try:
                      with open(fn, 'wb') as destfp:
                          shutil.copyfileobj(fp, destfp)
                  finally:
                      fp.close()
                      mode = info.external_attr >> 16
                      # if mode and regular file and any execute permissions for
                      # user/group/world?
                      if mode and stat.S_ISREG(mode) and mode & 0o111:
                          # make dest file have execute for user/group/world
                          # (chmod +x) no-op on windows per python docs
                          os.chmod(fn, (0o777 - current_umask() | 0o111))
      finally:
          zipfp.close()
docs: Unzip the file (with path `filename`) to the destination `location`.  All
      files are written based on system defaults and umask (i.e. permissions are
      not preserved), except that regular file members with any execute
      permissions (user, group, or world) have "chmod +x" applied after being
      written. Note that for windows, any execute changes using os.chmod are
      no-ops per the python docs.