1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-04 23:14:47 +00:00
This commit is contained in:
deadc0de6
2020-10-24 18:27:53 +02:00
parent 8f5b10ca29
commit a2a89a1a1f

View File

@@ -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"""