mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-08 21:19:15 +00:00
fix bug for #99
This commit is contained in:
@@ -188,6 +188,21 @@ class Cfg:
|
|||||||
self.lnk_settings = self.content[self.key_settings]
|
self.lnk_settings = self.content[self.key_settings]
|
||||||
self._complete_settings()
|
self._complete_settings()
|
||||||
|
|
||||||
|
# parse the profiles
|
||||||
|
self.lnk_profiles = self.content[self.key_profiles]
|
||||||
|
if self.lnk_profiles is None:
|
||||||
|
# ensures self.lnk_profiles is a dict
|
||||||
|
self.content[self.key_profiles] = {}
|
||||||
|
self.lnk_profiles = self.content[self.key_profiles]
|
||||||
|
for k, v in self.lnk_profiles.items():
|
||||||
|
if not v:
|
||||||
|
continue
|
||||||
|
if self.key_profiles_dots in v and \
|
||||||
|
v[self.key_profiles_dots] is None:
|
||||||
|
# if has the dotfiles entry but is empty
|
||||||
|
# ensures it's an empty list
|
||||||
|
v[self.key_profiles_dots] = []
|
||||||
|
|
||||||
# load external variables/dynvariables
|
# load external variables/dynvariables
|
||||||
if self.key_include_vars in self.lnk_settings:
|
if self.key_include_vars in self.lnk_settings:
|
||||||
paths = self.lnk_settings[self.key_include_vars]
|
paths = self.lnk_settings[self.key_include_vars]
|
||||||
@@ -225,21 +240,6 @@ class Cfg:
|
|||||||
for k, v in self.content[self.key_trans_w].items():
|
for k, v in self.content[self.key_trans_w].items():
|
||||||
self.trans_w[k] = Transform(k, v)
|
self.trans_w[k] = Transform(k, v)
|
||||||
|
|
||||||
# parse the profiles
|
|
||||||
self.lnk_profiles = self.content[self.key_profiles]
|
|
||||||
if self.lnk_profiles is None:
|
|
||||||
# ensures self.lnk_profiles is a dict
|
|
||||||
self.content[self.key_profiles] = {}
|
|
||||||
self.lnk_profiles = self.content[self.key_profiles]
|
|
||||||
for k, v in self.lnk_profiles.items():
|
|
||||||
if not v:
|
|
||||||
continue
|
|
||||||
if self.key_profiles_dots in v and \
|
|
||||||
v[self.key_profiles_dots] is None:
|
|
||||||
# if has the dotfiles entry but is empty
|
|
||||||
# ensures it's an empty list
|
|
||||||
v[self.key_profiles_dots] = []
|
|
||||||
|
|
||||||
# parse the dotfiles
|
# parse the dotfiles
|
||||||
# and construct the dict of objects per dotfile key
|
# and construct the dict of objects per dotfile key
|
||||||
if not self.content[self.key_dotfiles]:
|
if not self.content[self.key_dotfiles]:
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ tmpd=`mktemp -d --suffix='-dotdrop-tests'`
|
|||||||
extvars="${tmps}/variables.yaml"
|
extvars="${tmps}/variables.yaml"
|
||||||
extdvars="${tmps}/dynvariables.yaml"
|
extdvars="${tmps}/dynvariables.yaml"
|
||||||
pvars="${tmps}/p1_vars.yaml"
|
pvars="${tmps}/p1_vars.yaml"
|
||||||
|
pvarin="${tmps}/inprofile_vars.yaml"
|
||||||
|
pvarout="${tmps}/outprofile_vars.yaml"
|
||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
cat > ${cfg} << _EOF
|
cat > ${cfg} << _EOF
|
||||||
config:
|
config:
|
||||||
@@ -66,8 +68,10 @@ config:
|
|||||||
- "{{@@ var1 @@}}iables.yaml"
|
- "{{@@ var1 @@}}iables.yaml"
|
||||||
- "{{@@ dvar1 @@}}iables.yaml"
|
- "{{@@ dvar1 @@}}iables.yaml"
|
||||||
- "{{@@ profile @@}}_vars.yaml"
|
- "{{@@ profile @@}}_vars.yaml"
|
||||||
|
- "{{@@ xvar @@}}_vars.yaml"
|
||||||
variables:
|
variables:
|
||||||
var1: "var"
|
var1: "var"
|
||||||
|
xvar: outprofile
|
||||||
dynvariables:
|
dynvariables:
|
||||||
dvar1: "echo dynvar"
|
dvar1: "echo dynvar"
|
||||||
dotfiles:
|
dotfiles:
|
||||||
@@ -78,6 +82,8 @@ profiles:
|
|||||||
p1:
|
p1:
|
||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
|
variables:
|
||||||
|
xvar: inprofile
|
||||||
_EOF
|
_EOF
|
||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
@@ -100,6 +106,14 @@ variables:
|
|||||||
dynvariables:
|
dynvariables:
|
||||||
pdvar: "echo pdvar1"
|
pdvar: "echo pdvar1"
|
||||||
_EOF
|
_EOF
|
||||||
|
cat > ${pvarin} << _EOF
|
||||||
|
variables:
|
||||||
|
test: profileok
|
||||||
|
_EOF
|
||||||
|
cat > ${pvarout} << _EOF
|
||||||
|
variables:
|
||||||
|
test: profilenotok
|
||||||
|
_EOF
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "var1: {{@@ var1 @@}}" > ${tmps}/dotfiles/abc
|
echo "var1: {{@@ var1 @@}}" > ${tmps}/dotfiles/abc
|
||||||
@@ -113,6 +127,8 @@ echo "dvarb: {{@@ dvarb @@}}" >> ${tmps}/dotfiles/abc
|
|||||||
# from var file 3
|
# from var file 3
|
||||||
echo "pvar: {{@@ pvar @@}}" >> ${tmps}/dotfiles/abc
|
echo "pvar: {{@@ pvar @@}}" >> ${tmps}/dotfiles/abc
|
||||||
echo "pdvar: {{@@ pdvar @@}}" >> ${tmps}/dotfiles/abc
|
echo "pdvar: {{@@ pdvar @@}}" >> ${tmps}/dotfiles/abc
|
||||||
|
# from profile variable
|
||||||
|
echo "test: {{@@ test @@}}" >> ${tmps}/dotfiles/abc
|
||||||
|
|
||||||
#cat ${tmps}/dotfiles/abc
|
#cat ${tmps}/dotfiles/abc
|
||||||
|
|
||||||
@@ -129,6 +145,7 @@ grep '^varb: extvar2' ${tmpd}/abc >/dev/null
|
|||||||
grep '^dvarb: extdvar2' ${tmpd}/abc >/dev/null
|
grep '^dvarb: extdvar2' ${tmpd}/abc >/dev/null
|
||||||
grep '^pvar: pvar1' ${tmpd}/abc >/dev/null
|
grep '^pvar: pvar1' ${tmpd}/abc >/dev/null
|
||||||
grep '^pdvar: pdvar1' ${tmpd}/abc >/dev/null
|
grep '^pdvar: pdvar1' ${tmpd}/abc >/dev/null
|
||||||
|
grep '^test: profileok' ${tmpd}/abc >/dev/null
|
||||||
|
|
||||||
## CLEANING
|
## CLEANING
|
||||||
rm -rf ${tmps} ${tmpd}
|
rm -rf ${tmps} ${tmpd}
|
||||||
|
|||||||
Reference in New Issue
Block a user