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

fix bug for #177

This commit is contained in:
deadc0de6
2019-07-10 10:10:44 +02:00
parent 229a7797d0
commit 5e3dce92a9
2 changed files with 8 additions and 2 deletions

View File

@@ -223,7 +223,8 @@ class CfgYaml:
def _rec_resolve_vars(self, variables):
"""recursive resolve variables"""
t = Templategen(variables=variables)
default = self._get_variables_dict(self.profile)
t = Templategen(variables=self._merge_dict(default, variables))
for k in variables.keys():
val = variables[k]
while Templategen.var_is_template(val):
@@ -624,13 +625,15 @@ class CfgYaml:
extdict = self._load_yaml(path)
new = self._get_entry(extdict, key, mandatory=mandatory)
if patch_func:
if self.debug:
self.log.dbg('calling patch: {}'.format(patch_func))
new = patch_func(new)
if not new and mandatory:
err = 'no \"{}\" imported from \"{}\"'.format(key, path)
self.log.warn(err)
raise YamlException(err)
if self.debug:
self.log.dbg('new \"{}\": {}'.format(key, new))
self.log.dbg('imported \"{}\": {}'.format(key, new))
return new
########################################################

View File

@@ -94,6 +94,7 @@ variables:
varx: "exttest"
dynvariables:
evar1: "echo extevar1"
theprofile: "echo {{@@ profile @@}}"
_EOF
# create the dotfile
@@ -104,6 +105,7 @@ echo "dvar4: {{@@ dvar4 @@}}" >> ${tmps}/dotfiles/abc
echo "varx: {{@@ varx @@}}" >> ${tmps}/dotfiles/abc
echo "evar1: {{@@ evar1 @@}}" >> ${tmps}/dotfiles/abc
echo "provar: {{@@ provar @@}}" >> ${tmps}/dotfiles/abc
echo "theprofile: {{@@ theprofile @@}}" >> ${tmps}/dotfiles/abc
#cat ${tmps}/dotfiles/abc
@@ -119,6 +121,7 @@ grep '^dvar4: var1 var2 var3' ${tmpd}/abc >/dev/null
grep '^varx: profvarx' ${tmpd}/abc >/dev/null
grep '^evar1: extevar1' ${tmpd}/abc >/dev/null
grep '^provar: provar' ${tmpd}/abc >/dev/null
grep '^theprofile: p1' ${tmpd}/abc >/dev/null
rm -f ${tmpd}/abc