Skip to content

Commit

Permalink
fix bug #268
Browse files Browse the repository at this point in the history
  • Loading branch information
deadc0de6 committed Oct 24, 2020
1 parent 8f5b10c commit a2a89a1
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions dotdrop/cfg_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,16 @@ def __init__(self, path, profile=None, addprofiles=[], debug=False):
# public methods
########################################################

def _resolve_dotfile_link(self, link):
"""resolve dotfile link entry"""
newlink = self._template_item(link)
# check link value
if newlink not in self.allowed_link_val:
err = 'bad value: {}'.format(newlink)
self._log.err(err)
raise YamlException('config content error: {}'.format(err))
return newlink

def resolve_dotfile_src(self, src, templater=None):
"""resolve dotfile src path"""
newsrc = ''
Expand Down Expand Up @@ -1126,7 +1136,17 @@ def _template_dotfiles_entries(self):
if dst is None:
dotfile[self.key_dotfile_dst] = ''

# only keep dotfiles related to the selected profile
# resolve links before taking subset of
# dotfiles to avoid issues in upper layer
for dotfile in dotfiles.values():
# link
if self.key_dotfile_link in dotfile:
# normalize the link value
link = dotfile[self.key_dotfile_link]
newlink = self._resolve_dotfile_link(link)
dotfile[self.key_dotfile_link] = newlink

# only keep dotfiles related to the selected profile
pdfs = []
pro = self.profiles.get(self._profile, [])
if pro:
Expand Down Expand Up @@ -1156,17 +1176,6 @@ def _template_dotfiles_entries(self):
dst = dotfile[self.key_dotfile_dst]
newdst = self.resolve_dotfile_dst(dst, templater=self._tmpl)
dotfile[self.key_dotfile_dst] = newdst
# normalize the link value
if self.key_dotfile_link in dotfile:
# link
link = dotfile[self.key_dotfile_link]
newlink = self._template_item(link)
dotfile[self.key_dotfile_link] = newlink
# check link value
if newlink not in self.allowed_link_val:
err = 'bad value: {}'.format(newlink)
self._log.err(err)
raise YamlException('config content error: {}'.format(err))

def _rec_resolve_variables(self, variables):
"""recursive resolve variables"""
Expand Down

0 comments on commit a2a89a1

Please sign in to comment.