diff --git a/dotdrop/dotdrop.py b/dotdrop/dotdrop.py index d0f4740..7dbf9a6 100644 --- a/dotdrop/dotdrop.py +++ b/dotdrop/dotdrop.py @@ -46,7 +46,7 @@ Usage: dotdrop import [-ldVb] [-c ] [-p ] ... dotdrop compare [-Vb] [-c ] [-p ] [-o ] [-C ...] [-i ...] - dotdrop update [-fdVb] [-c ] ... + dotdrop update [-fdVb] [-c ] [-p ] ... dotdrop listfiles [-VTb] [-c ] [-p ] dotdrop list [-Vb] [-c ] dotdrop --help diff --git a/dotdrop/updater.py b/dotdrop/updater.py index 129d0e8..6151c57 100644 --- a/dotdrop/updater.py +++ b/dotdrop/updater.py @@ -28,6 +28,27 @@ class Updater: self.debug = debug self.log = Logger() + def update(self, path, profile): + """update the dotfile installed on path""" + if not os.path.lexists(path): + self.log.err('\"{}\" does not exist!'.format(path)) + return False + left = self._normalize(path) + dotfile = self._get_dotfile(left, profile) + if not dotfile: + return False + if self.debug: + self.log.dbg('updating {} from {}'.format(dotfile, path)) + + right = os.path.join(self.conf.abs_dotpath(self.dotpath), dotfile.src) + # expands user + left = os.path.expanduser(left) + right = os.path.expanduser(right) + # go through all files and update + if os.path.isdir(path): + return self._handle_dir(left, right) + return self._handle_file(left, right) + def _normalize(self, path): """normalize the path to match dotfile""" path = os.path.expanduser(path) @@ -52,27 +73,6 @@ class Updater: return None return subs[0] - def update(self, path, profile): - """update the dotfile installed on path""" - if not os.path.lexists(path): - self.log.err('\"{}\" does not exist!'.format(path)) - return False - left = self._normalize(path) - dotfile = self._get_dotfile(left, profile) - if not dotfile: - return False - if self.debug: - self.log.dbg('updating {} from {}'.format(dotfile, path)) - - right = os.path.join(self.conf.abs_dotpath(self.dotpath), dotfile.src) - # expands user - left = os.path.expanduser(left) - right = os.path.expanduser(right) - # go through all files and update - if os.path.isdir(path): - return self._handle_dir(left, right) - return self._handle_file(left, right) - def _is_template(self, path): if not Templategen.is_template(path): return False