class Iinitialize(object): def __init__(self, default_dotfiles, config): self._default_dotfiles = Path(default_dotfiles) self._config = config def run(self): self._config.dotfiles = self._default_dotfiles.resolve()
class Unlink(object): def __init__(self, dotfiles, home): self._dotfiles = Path(dotfiles) self._home = Path(home) _dotfiles_home = self._dotfiles / 'home' self._files_in_dotfiles_home = list(_dotfiles_home.rglob('*')) def run(self): for unlinkable in self._iter_unlinkables_in_home(): print('unlink: {}'.format(unlinkable)) unlinkable.unlink() def _iter_unlinkables_in_home(self): return (f for f in self._home.iterdir() if self._is_unlinkable(f)) def _is_unlinkable(self, f): return (f.is_symlink() and f.realpath in self._files_in_dotfiles_home)
def __init__(self, dotfiles, home): self._dotfiles = Path(dotfiles) self._home = Path(home) _dotfiles_home = self._dotfiles / 'home' self._files_in_dotfiles_home = list(_dotfiles_home.rglob('*'))
def __init__(self, default_dotfiles, config): self._default_dotfiles = Path(default_dotfiles) self._config = config