mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-04 20:19:46 +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._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
|
||||
if self.key_include_vars in self.lnk_settings:
|
||||
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():
|
||||
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
|
||||
# and construct the dict of objects per dotfile key
|
||||
if not self.content[self.key_dotfiles]:
|
||||
|
||||
@@ -56,6 +56,8 @@ tmpd=`mktemp -d --suffix='-dotdrop-tests'`
|
||||
extvars="${tmps}/variables.yaml"
|
||||
extdvars="${tmps}/dynvariables.yaml"
|
||||
pvars="${tmps}/p1_vars.yaml"
|
||||
pvarin="${tmps}/inprofile_vars.yaml"
|
||||
pvarout="${tmps}/outprofile_vars.yaml"
|
||||
cfg="${tmps}/config.yaml"
|
||||
cat > ${cfg} << _EOF
|
||||
config:
|
||||
@@ -66,8 +68,10 @@ config:
|
||||
- "{{@@ var1 @@}}iables.yaml"
|
||||
- "{{@@ dvar1 @@}}iables.yaml"
|
||||
- "{{@@ profile @@}}_vars.yaml"
|
||||
- "{{@@ xvar @@}}_vars.yaml"
|
||||
variables:
|
||||
var1: "var"
|
||||
xvar: outprofile
|
||||
dynvariables:
|
||||
dvar1: "echo dynvar"
|
||||
dotfiles:
|
||||
@@ -78,6 +82,8 @@ profiles:
|
||||
p1:
|
||||
dotfiles:
|
||||
- f_abc
|
||||
variables:
|
||||
xvar: inprofile
|
||||
_EOF
|
||||
#cat ${cfg}
|
||||
|
||||
@@ -100,6 +106,14 @@ variables:
|
||||
dynvariables:
|
||||
pdvar: "echo pdvar1"
|
||||
_EOF
|
||||
cat > ${pvarin} << _EOF
|
||||
variables:
|
||||
test: profileok
|
||||
_EOF
|
||||
cat > ${pvarout} << _EOF
|
||||
variables:
|
||||
test: profilenotok
|
||||
_EOF
|
||||
|
||||
# create the dotfile
|
||||
echo "var1: {{@@ var1 @@}}" > ${tmps}/dotfiles/abc
|
||||
@@ -113,6 +127,8 @@ echo "dvarb: {{@@ dvarb @@}}" >> ${tmps}/dotfiles/abc
|
||||
# from var file 3
|
||||
echo "pvar: {{@@ pvar @@}}" >> ${tmps}/dotfiles/abc
|
||||
echo "pdvar: {{@@ pdvar @@}}" >> ${tmps}/dotfiles/abc
|
||||
# from profile variable
|
||||
echo "test: {{@@ test @@}}" >> ${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 '^pvar: pvar1' ${tmpd}/abc >/dev/null
|
||||
grep '^pdvar: pdvar1' ${tmpd}/abc >/dev/null
|
||||
grep '^test: profileok' ${tmpd}/abc >/dev/null
|
||||
|
||||
## CLEANING
|
||||
rm -rf ${tmps} ${tmpd}
|
||||
|
||||
Reference in New Issue
Block a user