diff --git a/dotdrop/cfg_yaml.py b/dotdrop/cfg_yaml.py index 94fe490..b82db0a 100644 --- a/dotdrop/cfg_yaml.py +++ b/dotdrop/cfg_yaml.py @@ -253,6 +253,16 @@ class CfgYaml: # 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 = '' @@ -1126,7 +1136,17 @@ class CfgYaml: 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: @@ -1156,17 +1176,6 @@ class CfgYaml: 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"""