From 9d0c30e63319a47672e45830c2e111de028bf99d Mon Sep 17 00:00:00 2001 From: deadc0de6 Date: Sun, 9 Jun 2019 18:04:34 +0200 Subject: [PATCH] migrate trans to trans_read --- dotdrop/cfg_yaml.py | 11 +++++++---- tests/helpers.py | 2 +- tests/test_import.py | 4 ++-- tests/test_install.py | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/dotdrop/cfg_yaml.py b/dotdrop/cfg_yaml.py index 4dfc8db..41e7369 100644 --- a/dotdrop/cfg_yaml.py +++ b/dotdrop/cfg_yaml.py @@ -84,7 +84,7 @@ class CfgYaml: self._fix_deprecated(self.yaml_dict) self._parse_main_yaml(self.yaml_dict) if self.debug: - self.log.dbg('current dict: {}'.format(self.yaml_dict)) + self.log.dbg('before normalization: {}'.format(self.yaml_dict)) # resolve variables allvars = self._merge_and_apply_variables() @@ -97,6 +97,8 @@ class CfgYaml: self._resolve_rest() # patch dotfiles paths self._resolve_dotfile_paths() + if self.debug: + self.log.dbg('after normalization: {}'.format(self.yaml_dict)) def _parse_main_yaml(self, dic): """parse the different blocks""" @@ -142,7 +144,8 @@ class CfgYaml: key = self.key_trans_r if self.old_key_trans_r in dic: 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.trans_r = deepcopy(self.ori_trans_r) if self.debug: @@ -304,10 +307,10 @@ class CfgYaml: else: new[k] = v # 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\"' 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] new[k] = v return new diff --git a/tests/helpers.py b/tests/helpers.py index 836101b..80cc8d0 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -238,7 +238,7 @@ def populate_fake_config(config, dotfiles={}, profiles={}, actions={}, config['dotfiles'] = dotfiles config['profiles'] = profiles config['actions'] = actions - config['trans'] = trans + config['trans_read'] = trans config['trans_write'] = trans_write config['variables'] = variables config['dynvariables'] = dynvariables diff --git a/tests/test_import.py b/tests/test_import.py index 801ff55..08df58c 100644 --- a/tests/test_import.py +++ b/tests/test_import.py @@ -349,7 +349,7 @@ class TestImport(unittest.TestCase): self.assertFalse(any(a.endswith('ing') for a in actions)) # testing transformations - transformations = y['trans'].keys() + transformations = y['trans_read'].keys() self.assertTrue(all(t.endswith('ed') for t in transformations)) self.assertFalse(any(t.endswith('ing') for t in transformations)) transformations = y['trans_write'].keys() @@ -391,7 +391,7 @@ class TestImport(unittest.TestCase): self.assertFalse(any(action.endswith('ed') for action in actions)) # testing transformations - transformations = y['trans'].keys() + transformations = y['trans_read'].keys() self.assertTrue(all(t.endswith('ing') for t in transformations)) self.assertFalse(any(t.endswith('ed') for t in transformations)) transformations = y['trans_write'].keys() diff --git a/tests/test_install.py b/tests/test_install.py index af68d97..5ba35cb 100644 --- a/tests/test_install.py +++ b/tests/test_install.py @@ -65,7 +65,7 @@ exec bspwm f.write(' - {}\n'.format(action.key)) if 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(' {}:\n'.format(profile)) f.write(' dotfiles:\n')