mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-11 03:49:16 +00:00
fix update usage (adding profile switch)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user