def _stash(self, path): best = None for save_dir in self._save_dirs: if not path.startswith(save_dir.original + os.sep): continue if not best or len(save_dir.original) > len(best.original): best = save_dir if best is None: best = AdjacentTempDirectory(os.path.dirname(path)) best.create() self._save_dirs.append(best) return os.path.join(best.path, os.path.relpath(path, best.original))
def _stash(self, path): best = None for save_dir in self._save_dirs: if not path.startswith(save_dir.original + os.sep): continue if not best or len(save_dir.original) > len(best.original): best = save_dir if best is None: best = AdjacentTempDirectory(os.path.dirname(path)) best.create() self._save_dirs.append(best) return os.path.join(best.path, os.path.relpath(path, best.original))
def _get_directory_stash(self, path): """Stashes a directory. Directories are stashed adjacent to their original location if possible, or else moved/copied into the user's temp dir.""" try: save_dir = AdjacentTempDirectory(path) save_dir.create() except OSError: save_dir = TempDirectory(kind="uninstall") save_dir.create() self._save_dirs[os.path.normcase(path)] = save_dir return save_dir.path
def _get_directory_stash(self, path): # type: (str) -> str """Stashes a directory. Directories are stashed adjacent to their original location if possible, or else moved/copied into the user's temp dir.""" try: save_dir = AdjacentTempDirectory(path) # type: TempDirectory save_dir.create() except OSError: save_dir = TempDirectory(kind="uninstall") save_dir.create() self._save_dirs[os.path.normcase(path)] = save_dir return save_dir.path