mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-11 05:34:17 +00:00
migrate trans to trans_read
This commit is contained in:
@@ -84,7 +84,7 @@ class CfgYaml:
|
|||||||
self._fix_deprecated(self.yaml_dict)
|
self._fix_deprecated(self.yaml_dict)
|
||||||
self._parse_main_yaml(self.yaml_dict)
|
self._parse_main_yaml(self.yaml_dict)
|
||||||
if self.debug:
|
if self.debug:
|
||||||
self.log.dbg('current dict: {}'.format(self.yaml_dict))
|
self.log.dbg('before normalization: {}'.format(self.yaml_dict))
|
||||||
|
|
||||||
# resolve variables
|
# resolve variables
|
||||||
allvars = self._merge_and_apply_variables()
|
allvars = self._merge_and_apply_variables()
|
||||||
@@ -97,6 +97,8 @@ class CfgYaml:
|
|||||||
self._resolve_rest()
|
self._resolve_rest()
|
||||||
# patch dotfiles paths
|
# patch dotfiles paths
|
||||||
self._resolve_dotfile_paths()
|
self._resolve_dotfile_paths()
|
||||||
|
if self.debug:
|
||||||
|
self.log.dbg('after normalization: {}'.format(self.yaml_dict))
|
||||||
|
|
||||||
def _parse_main_yaml(self, dic):
|
def _parse_main_yaml(self, dic):
|
||||||
"""parse the different blocks"""
|
"""parse the different blocks"""
|
||||||
@@ -142,7 +144,8 @@ class CfgYaml:
|
|||||||
key = self.key_trans_r
|
key = self.key_trans_r
|
||||||
if self.old_key_trans_r in dic:
|
if self.old_key_trans_r in dic:
|
||||||
self.log.warn('\"trans\" is deprecated, please use \"trans_read\"')
|
self.log.warn('\"trans\" is deprecated, please use \"trans_read\"')
|
||||||
key = self.old_key_trans_r
|
dic[self.key_trans_r] = dic[self.old_key_trans_r]
|
||||||
|
del dic[self.old_key_trans_r]
|
||||||
self.ori_trans_r = self._get_entry(dic, key, mandatory=False)
|
self.ori_trans_r = self._get_entry(dic, key, mandatory=False)
|
||||||
self.trans_r = deepcopy(self.ori_trans_r)
|
self.trans_r = deepcopy(self.ori_trans_r)
|
||||||
if self.debug:
|
if self.debug:
|
||||||
@@ -304,10 +307,10 @@ class CfgYaml:
|
|||||||
else:
|
else:
|
||||||
new[k] = v
|
new[k] = v
|
||||||
# fix deprecated trans key
|
# fix deprecated trans key
|
||||||
if self.old_key_trans_r in k:
|
if self.old_key_trans_r in v:
|
||||||
msg = '\"trans\" is deprecated, please use \"trans_read\"'
|
msg = '\"trans\" is deprecated, please use \"trans_read\"'
|
||||||
self.log.warn(msg)
|
self.log.warn(msg)
|
||||||
v[self.key_trans_r] = v[self.old_key_trans_r].copy()
|
v[self.key_trans_r] = v[self.old_key_trans_r]
|
||||||
del v[self.old_key_trans_r]
|
del v[self.old_key_trans_r]
|
||||||
new[k] = v
|
new[k] = v
|
||||||
return new
|
return new
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ def populate_fake_config(config, dotfiles={}, profiles={}, actions={},
|
|||||||
config['dotfiles'] = dotfiles
|
config['dotfiles'] = dotfiles
|
||||||
config['profiles'] = profiles
|
config['profiles'] = profiles
|
||||||
config['actions'] = actions
|
config['actions'] = actions
|
||||||
config['trans'] = trans
|
config['trans_read'] = trans
|
||||||
config['trans_write'] = trans_write
|
config['trans_write'] = trans_write
|
||||||
config['variables'] = variables
|
config['variables'] = variables
|
||||||
config['dynvariables'] = dynvariables
|
config['dynvariables'] = dynvariables
|
||||||
|
|||||||
@@ -349,7 +349,7 @@ class TestImport(unittest.TestCase):
|
|||||||
self.assertFalse(any(a.endswith('ing') for a in actions))
|
self.assertFalse(any(a.endswith('ing') for a in actions))
|
||||||
|
|
||||||
# testing transformations
|
# testing transformations
|
||||||
transformations = y['trans'].keys()
|
transformations = y['trans_read'].keys()
|
||||||
self.assertTrue(all(t.endswith('ed') for t in transformations))
|
self.assertTrue(all(t.endswith('ed') for t in transformations))
|
||||||
self.assertFalse(any(t.endswith('ing') for t in transformations))
|
self.assertFalse(any(t.endswith('ing') for t in transformations))
|
||||||
transformations = y['trans_write'].keys()
|
transformations = y['trans_write'].keys()
|
||||||
@@ -391,7 +391,7 @@ class TestImport(unittest.TestCase):
|
|||||||
self.assertFalse(any(action.endswith('ed') for action in actions))
|
self.assertFalse(any(action.endswith('ed') for action in actions))
|
||||||
|
|
||||||
# testing transformations
|
# testing transformations
|
||||||
transformations = y['trans'].keys()
|
transformations = y['trans_read'].keys()
|
||||||
self.assertTrue(all(t.endswith('ing') for t in transformations))
|
self.assertTrue(all(t.endswith('ing') for t in transformations))
|
||||||
self.assertFalse(any(t.endswith('ed') for t in transformations))
|
self.assertFalse(any(t.endswith('ed') for t in transformations))
|
||||||
transformations = y['trans_write'].keys()
|
transformations = y['trans_write'].keys()
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ exec bspwm
|
|||||||
f.write(' - {}\n'.format(action.key))
|
f.write(' - {}\n'.format(action.key))
|
||||||
if d.trans_r:
|
if d.trans_r:
|
||||||
for tr in d.trans_r:
|
for tr in d.trans_r:
|
||||||
f.write(' trans: {}\n'.format(tr.key))
|
f.write(' trans_read: {}\n'.format(tr.key))
|
||||||
f.write('profiles:\n')
|
f.write('profiles:\n')
|
||||||
f.write(' {}:\n'.format(profile))
|
f.write(' {}:\n'.format(profile))
|
||||||
f.write(' dotfiles:\n')
|
f.write(' dotfiles:\n')
|
||||||
|
|||||||
Reference in New Issue
Block a user