mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-05 18:28:55 +00:00
Testing merge funcationalities in import_configs
This commit is contained in:
@@ -14,6 +14,7 @@ from dotdrop.logger import Logger
|
||||
|
||||
|
||||
class Cmd:
|
||||
eq_ignore = ('log',)
|
||||
|
||||
def __init__(self, key, action):
|
||||
"""constructor
|
||||
@@ -31,7 +32,17 @@ class Cmd:
|
||||
return 'cmd({})'.format(self.__str__())
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.__dict__ == other.__dict__
|
||||
self_dict = {
|
||||
k: v
|
||||
for k, v in self.__dict__.items()
|
||||
if k not in self.eq_ignore
|
||||
}
|
||||
other_dict = {
|
||||
k: v
|
||||
for k, v in other.__dict__.items()
|
||||
if k not in self.eq_ignore
|
||||
}
|
||||
return self_dict == other_dict
|
||||
|
||||
def __hash__(self):
|
||||
return hash(self.key) ^ hash(self.action)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user