mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-10 05:44:17 +00:00
fix bug for #177
This commit is contained in:
@@ -223,7 +223,8 @@ class CfgYaml:
|
|||||||
|
|
||||||
def _rec_resolve_vars(self, variables):
|
def _rec_resolve_vars(self, variables):
|
||||||
"""recursive resolve 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():
|
for k in variables.keys():
|
||||||
val = variables[k]
|
val = variables[k]
|
||||||
while Templategen.var_is_template(val):
|
while Templategen.var_is_template(val):
|
||||||
@@ -624,13 +625,15 @@ class CfgYaml:
|
|||||||
extdict = self._load_yaml(path)
|
extdict = self._load_yaml(path)
|
||||||
new = self._get_entry(extdict, key, mandatory=mandatory)
|
new = self._get_entry(extdict, key, mandatory=mandatory)
|
||||||
if patch_func:
|
if patch_func:
|
||||||
|
if self.debug:
|
||||||
|
self.log.dbg('calling patch: {}'.format(patch_func))
|
||||||
new = patch_func(new)
|
new = patch_func(new)
|
||||||
if not new and mandatory:
|
if not new and mandatory:
|
||||||
err = 'no \"{}\" imported from \"{}\"'.format(key, path)
|
err = 'no \"{}\" imported from \"{}\"'.format(key, path)
|
||||||
self.log.warn(err)
|
self.log.warn(err)
|
||||||
raise YamlException(err)
|
raise YamlException(err)
|
||||||
if self.debug:
|
if self.debug:
|
||||||
self.log.dbg('new \"{}\": {}'.format(key, new))
|
self.log.dbg('imported \"{}\": {}'.format(key, new))
|
||||||
return new
|
return new
|
||||||
|
|
||||||
########################################################
|
########################################################
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ variables:
|
|||||||
varx: "exttest"
|
varx: "exttest"
|
||||||
dynvariables:
|
dynvariables:
|
||||||
evar1: "echo extevar1"
|
evar1: "echo extevar1"
|
||||||
|
theprofile: "echo {{@@ profile @@}}"
|
||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
@@ -104,6 +105,7 @@ echo "dvar4: {{@@ dvar4 @@}}" >> ${tmps}/dotfiles/abc
|
|||||||
echo "varx: {{@@ varx @@}}" >> ${tmps}/dotfiles/abc
|
echo "varx: {{@@ varx @@}}" >> ${tmps}/dotfiles/abc
|
||||||
echo "evar1: {{@@ evar1 @@}}" >> ${tmps}/dotfiles/abc
|
echo "evar1: {{@@ evar1 @@}}" >> ${tmps}/dotfiles/abc
|
||||||
echo "provar: {{@@ provar @@}}" >> ${tmps}/dotfiles/abc
|
echo "provar: {{@@ provar @@}}" >> ${tmps}/dotfiles/abc
|
||||||
|
echo "theprofile: {{@@ theprofile @@}}" >> ${tmps}/dotfiles/abc
|
||||||
|
|
||||||
#cat ${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 '^varx: profvarx' ${tmpd}/abc >/dev/null
|
||||||
grep '^evar1: extevar1' ${tmpd}/abc >/dev/null
|
grep '^evar1: extevar1' ${tmpd}/abc >/dev/null
|
||||||
grep '^provar: provar' ${tmpd}/abc >/dev/null
|
grep '^provar: provar' ${tmpd}/abc >/dev/null
|
||||||
|
grep '^theprofile: p1' ${tmpd}/abc >/dev/null
|
||||||
|
|
||||||
rm -f ${tmpd}/abc
|
rm -f ${tmpd}/abc
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user