mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-04 22:04:44 +00:00
fix dynvariables being executed twice (#83)
This commit is contained in:
@@ -118,9 +118,9 @@ class Cfg:
|
||||
if not self._load_file():
|
||||
raise ValueError('config is not valid')
|
||||
|
||||
def eval_dotfiles(self, profile, debug=False):
|
||||
def eval_dotfiles(self, profile, variables, debug=False):
|
||||
"""resolve dotfiles src/dst/actions templating for this profile"""
|
||||
t = Templategen(variables=self.get_variables(profile, debug=debug))
|
||||
t = Templategen(variables=variables)
|
||||
for d in self.get_dotfiles(profile):
|
||||
# src and dst path
|
||||
d.src = t.generate_string(d.src)
|
||||
|
||||
@@ -218,8 +218,8 @@ def cmd_update(opts, conf, paths, iskey=False, ignore=[], showpatch=False):
|
||||
"""update the dotfile(s) from path(s) or key(s)"""
|
||||
ret = True
|
||||
updater = Updater(conf, opts['dotpath'], opts['profile'],
|
||||
opts['dry'], opts['safe'], iskey=iskey,
|
||||
debug=opts['debug'], ignore=[],
|
||||
opts['variables'], opts['dry'], opts['safe'],
|
||||
iskey=iskey, debug=opts['debug'], ignore=[],
|
||||
showpatch=showpatch)
|
||||
if not iskey:
|
||||
# update paths
|
||||
@@ -461,7 +461,8 @@ def main():
|
||||
LOG.dbg('configs:\n{}'.format(conf.dump()))
|
||||
|
||||
# resolve dynamic paths
|
||||
conf.eval_dotfiles(opts['profile'], debug=opts['debug'])
|
||||
conf.eval_dotfiles(opts['profile'], opts['variables'],
|
||||
debug=opts['debug'])
|
||||
|
||||
if ENV_NOBANNER not in os.environ \
|
||||
and opts['banner'] \
|
||||
|
||||
@@ -20,11 +20,12 @@ TILD = '~'
|
||||
|
||||
class Updater:
|
||||
|
||||
def __init__(self, conf, dotpath, profile, dry, safe,
|
||||
def __init__(self, conf, dotpath, profile, variables, dry, safe,
|
||||
iskey=False, debug=False, ignore=[], showpatch=False):
|
||||
self.conf = conf
|
||||
self.dotpath = dotpath
|
||||
self.profile = profile
|
||||
self.variables = variables
|
||||
self.dry = dry
|
||||
self.safe = safe
|
||||
self.iskey = iskey
|
||||
@@ -155,8 +156,7 @@ class Updater:
|
||||
|
||||
def _resolve_template(self, tpath):
|
||||
"""resolve the template to a temporary file"""
|
||||
variables = self.conf.get_variables(self.profile)
|
||||
t = Templategen(variables=variables, base=self.dotpath,
|
||||
t = Templategen(variables=self.variables, base=self.dotpath,
|
||||
debug=self.debug)
|
||||
return t.generate(tpath)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user