1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-06 00:53:04 +00:00

allow empty src/dst for dotfiles

This commit is contained in:
deadc0de6
2020-01-29 14:51:48 +01:00
parent 873a22bab6
commit 7498be51b6
3 changed files with 125 additions and 14 deletions

View File

@@ -221,19 +221,29 @@ class CfgYaml:
for dotfile in self.dotfiles.values():
# src
src = dotfile[self.key_dotfile_src]
new = t.generate_string(src)
if new != src and self.debug:
self.log.dbg('dotfile: {} -> {}'.format(src, new))
src = new
src = os.path.join(self.settings[self.key_settings_dotpath], src)
dotfile[self.key_dotfile_src] = self._norm_path(src)
if not src:
dotfile[self.key_dotfile_src] = ''
else:
new = t.generate_string(src)
if new != src and self.debug:
msg = 'dotfile src: \"{}\" -> \"{}\"'.format(src, new)
self.log.dbg(msg)
src = new
src = os.path.join(self.settings[self.key_settings_dotpath],
src)
dotfile[self.key_dotfile_src] = self._norm_path(src)
# dst
dst = dotfile[self.key_dotfile_dst]
new = t.generate_string(dst)
if new != dst and self.debug:
self.log.dbg('dotfile: {} -> {}'.format(dst, new))
dst = new
dotfile[self.key_dotfile_dst] = self._norm_path(dst)
if not dst:
dotfile[self.key_dotfile_dst] = ''
else:
new = t.generate_string(dst)
if new != dst and self.debug:
msg = 'dotfile dst: \"{}\" -> \"{}\"'.format(dst, new)
self.log.dbg(msg)
dst = new
dotfile[self.key_dotfile_dst] = self._norm_path(dst)
def _rec_resolve_vars(self, variables):
"""recursive resolve variables"""
@@ -980,6 +990,8 @@ class CfgYaml:
def _norm_path(self, path):
"""resolve a path either absolute or relative to config path"""
if not path:
return path
path = os.path.expanduser(path)
if not os.path.isabs(path):
d = os.path.dirname(self.path)

View File

@@ -68,7 +68,11 @@ class Installer:
- False, None : ignored
"""
if self.debug:
self.log.dbg('install {} to {}'.format(src, dst))
self.log.dbg('install \"{}\" to \"{}\"'.format(src, dst))
if not dst or not src:
if self.debug:
self.log.dbg('empty dst for {}'.format(src))
return True, None
self.action_executed = False
src = os.path.join(self.base, os.path.expanduser(src))
if not os.path.exists(src):
@@ -107,7 +111,11 @@ class Installer:
- False, None : ignored
"""
if self.debug:
self.log.dbg('link {} to {}'.format(src, dst))
self.log.dbg('link \"{}\" to \"{}\"'.format(src, dst))
if not dst or not src:
if self.debug:
self.log.dbg('empty dst for {}'.format(src))
return True, None
self.action_executed = False
src = os.path.normpath(os.path.join(self.base,
os.path.expanduser(src)))
@@ -144,7 +152,11 @@ class Installer:
- False, None, ignored
"""
if self.debug:
self.log.dbg('link_children {} to {}'.format(src, dst))
self.log.dbg('link_children \"{}\" to \"{}\"'.format(src, dst))
if not dst or not src:
if self.debug:
self.log.dbg('empty dst for {}'.format(src))
return True, None
self.action_executed = False
parent = os.path.join(self.base, os.path.expanduser(src))