def _cleanup_actions(self):
        appdir = self.appdir
        vsdir = self._get_versions_dir()
        best_version = get_best_version(vsdir)
        new_version = get_best_version(vsdir, include_partial_installs=True)
        #  If there's a partial install we must complete it, since it
        #  could have left exes in the bootstrap env and we don't want
        #  to accidentally delete their dependencies.
        if best_version != new_version:
            (_, v, _) = split_app_version(new_version)
            yield (self.install_version, (v,))
            best_version = new_version
        #  TODO: remove compatability hooks for ESKY_APPDATA_DIR=""
        if vsdir == appdir and ESKY_APPDATA_DIR:
            appdatadir = os.path.join(appdir, ESKY_APPDATA_DIR)
            if os.path.isdir(appdatadir) and os.listdir(appdatadir):
                new_version = get_best_version(appdatadir,
                                               include_partial_installs=True)
                if best_version != new_version:
                    (_, v, _) = split_app_version(new_version)
                    yield (self.install_version, (v,))
                    best_version = new_version
        #  Now we can safely remove all the old versions.
        #  We except the currently-executing version, and silently
        #  ignore any locked versions.
        manifest = self._version_manifest(best_version)
        manifest.add("updates")
        manifest.add("locked")
        manifest.add(best_version)
        if self.active_version:
            if self.active_version != split_app_version(best_version)[1]:
                yield lambda: False
            manifest.add(self.active_version)
        # TODO: remove compatability hooks for ESKY_APPDATA_DIR=""
        for tdir in (appdir, vsdir):
            for nm in os.listdir(tdir):
                if nm not in manifest:
                    fullnm = os.path.join(tdir, nm)
                    if ".old." in nm or nm.endswith(".old"):
                        #  It's a temporary backup file; remove it.
                        yield (self._try_remove, (tdir, nm, manifest,))
                    elif not os.path.isdir(fullnm):
                        #  It's an unaccounted-for file in the bootstrap env.
                        #  Leave it alone.
                        pass
                    elif is_version_dir(fullnm):
                        #  It's an installed-but-obsolete version.  Properly
                        #  uninstall it so it will clean up the bootstrap env.
                        (_, v, _) = split_app_version(nm)
                        try:
                            yield (self.uninstall_version, (v,))
                        except VersionLockedError:
                            yield lambda: False
                        else:
                            yield (self._try_remove, (tdir, nm, manifest,))
                    elif is_uninstalled_version_dir(fullnm):
                        #  It's a partially-removed version; finish removing it.
                        yield (self._try_remove, (tdir, nm, manifest,))
                    else:
                        for (_, _, filenms) in os.walk(fullnm):
                            if filenms:
                                #  It contains unaccounted-for files in the
                                #  bootstrap env. Can't prove it's safe to
                                #  remove, so leave it alone.
                                break
                        else:
                            #  It's an empty directory structure, remove it.
                            yield (self._try_remove, (tdir, nm, manifest,))
        #  If there are pending overwrites, try to do them.
        ovrdir = os.path.join(vsdir, best_version, ESKY_CONTROL_DIR,
                              "overwrite")
        if os.path.exists(ovrdir):
            try:
                for (dirnm, _, filenms) in os.walk(ovrdir, topdown=False):
                    for nm in filenms:
                        ovrsrc = os.path.join(dirnm, nm)
                        ovrdst = os.path.join(appdir, ovrsrc[len(ovrdir)+1:])
                        yield (self._overwrite, (ovrsrc, ovrdst,))
                        yield (os.unlink, (ovrsrc,))
                    yield (os.rmdir, (dirnm,))
            except EnvironmentError:
                yield lambda: False
        #  Get the VersionFinder to clean up after itself
        if self.version_finder is not None:
            if self.version_finder.needs_cleanup(self):
                yield (self.version_finder.cleanup, (self,))
Get all known variants of the given jobconf variable.
dataset/ETHPy150Open cloudmatrix/esky/esky/__init__.py/Esky._cleanup_actions--crossover with--dataset/ETHPy150Open Yelp/mrjob/mrjob/compat.py/translate_jobconf_for_all_versions