mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-10 03:24:17 +00:00
add profile to all other variables
This commit is contained in:
@@ -120,8 +120,7 @@ class Cfg:
|
||||
|
||||
def eval_dotfiles(self, profile, debug=False):
|
||||
"""resolve dotfiles src/dst templating"""
|
||||
t = Templategen(profile=profile,
|
||||
variables=self.get_variables(profile),
|
||||
t = Templategen(variables=self.get_variables(profile),
|
||||
debug=debug)
|
||||
for d in self.get_dotfiles(profile):
|
||||
d.src = t.generate_string(d.src)
|
||||
@@ -627,6 +626,9 @@ class Cfg:
|
||||
"""return the variables for this profile"""
|
||||
variables = {}
|
||||
|
||||
# profile variable
|
||||
variables['profile'] = profile
|
||||
|
||||
# global variables
|
||||
if self.key_variables in self.content:
|
||||
variables.update(self.content[self.key_variables])
|
||||
|
||||
@@ -89,8 +89,8 @@ def cmd_install(opts, conf, temporary=False, keys=[]):
|
||||
LOG.warn(msg.format(opts['profile']))
|
||||
return False
|
||||
|
||||
t = Templategen(profile=opts['profile'], base=opts['dotpath'],
|
||||
variables=opts['variables'], debug=opts['debug'])
|
||||
t = Templategen(base=opts['dotpath'], variables=opts['variables'],
|
||||
debug=opts['debug'])
|
||||
tmpdir = None
|
||||
if temporary:
|
||||
tmpdir = get_tmpdir()
|
||||
@@ -160,8 +160,8 @@ def cmd_compare(opts, conf, tmp, focus=[], ignore=[]):
|
||||
if len(selected) < 1:
|
||||
return False
|
||||
|
||||
t = Templategen(profile=opts['profile'], base=opts['dotpath'],
|
||||
variables=opts['variables'], debug=opts['debug'])
|
||||
t = Templategen(base=opts['dotpath'], variables=opts['variables'],
|
||||
debug=opts['debug'])
|
||||
inst = Installer(create=opts['create'], backup=opts['backup'],
|
||||
dry=opts['dry'], base=opts['dotpath'],
|
||||
workdir=opts['workdir'], debug=opts['debug'])
|
||||
|
||||
@@ -23,7 +23,7 @@ COMMENT_END = '@@#}'
|
||||
|
||||
class Templategen:
|
||||
|
||||
def __init__(self, profile='', base='.', variables={}, debug=False):
|
||||
def __init__(self, base='.', variables={}, debug=False):
|
||||
self.base = base.rstrip(os.sep)
|
||||
self.debug = debug
|
||||
self.log = Logger()
|
||||
@@ -39,8 +39,6 @@ class Templategen:
|
||||
comment_end_string=COMMENT_END)
|
||||
# adding variables
|
||||
self.env.globals['env'] = os.environ
|
||||
if profile:
|
||||
self.env.globals['profile'] = profile
|
||||
self.env.globals.update(variables)
|
||||
# adding header method
|
||||
self.env.globals['header'] = self._header
|
||||
|
||||
Reference in New Issue
Block a user