1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-07 19:44:20 +00:00

Testing merge funcationalities in import_configs

This commit is contained in:
Davide Laezza
2019-04-22 00:38:33 +02:00
parent bcf89478ba
commit 124336ed57
4 changed files with 305 additions and 65 deletions

View File

@@ -154,6 +154,9 @@ class Cfg:
if not self._load_config(profile=profile):
raise ValueError('config is not valid')
def __eq__(self, other):
return self.cfgpath == other.cfgpath
def eval_dotfiles(self, profile, variables, debug=False):
"""resolve dotfiles src/dst/actions templating for this profile"""
t = Templategen(variables=variables)
@@ -297,7 +300,11 @@ class Cfg:
# If read transformations are None, replaces them with empty dict
try:
read_trans = self.content[self.key_trans_r] or {}
self.trans_r = {k: Transform(k, v) for k, v in read_trans.items()}
self.trans_r.update({
k: Transform(k, v)
for k, v
in read_trans.items()
})
except KeyError:
pass
@@ -305,7 +312,11 @@ class Cfg:
# If write transformations are None, replaces them with empty dict
try:
read_trans = self.content[self.key_trans_w] or {}
self.trans_w = {k: Transform(k, v) for k, v in read_trans.items()}
self.trans_w.update({
k: Transform(k, v)
for k, v
in read_trans.items()
})
except KeyError:
pass
@@ -462,6 +473,14 @@ class Cfg:
raise ValueError(
'external config file not found: {}'.format(config_path))
list_settings = (
(k, v)
for k, v in ext_config.lnk_settings.items()
if isinstance(v, list)
)
for k, v in list_settings:
self.lnk_settings[k] += v
ext_members = (
(name, member)
for name, member in inspect.getmembers(ext_config, is_dict)