1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-10 17:59:14 +00:00

refactor deprecated entry

This commit is contained in:
deadc0de6
2020-10-11 15:02:41 +02:00
parent f845dd9d42
commit dbcd267009

View File

@@ -56,7 +56,6 @@ class CfgYaml:
key_dotfile_dst = 'dst' key_dotfile_dst = 'dst'
key_dotfile_link = 'link' key_dotfile_link = 'link'
key_dotfile_actions = 'actions' key_dotfile_actions = 'actions'
key_dotfile_link_children = 'link_children'
key_dotfile_noempty = 'ignoreempty' key_dotfile_noempty = 'ignoreempty'
# profile # profile
@@ -916,26 +915,27 @@ class CfgYaml:
def _fix_deprecated_link_by_default(self, yamldict): def _fix_deprecated_link_by_default(self, yamldict):
"""fix deprecated link_by_default""" """fix deprecated link_by_default"""
key = 'link_by_default' old_key = 'link_by_default'
newkey = self.key_imp_link newkey = self.key_imp_link
if self.key_settings not in yamldict: if self.key_settings not in yamldict:
return return
if not yamldict[self.key_settings]: if not yamldict[self.key_settings]:
return return
config = yamldict[self.key_settings] config = yamldict[self.key_settings]
if key not in config: if old_key not in config:
return return
if config[key]: if config[old_key]:
config[newkey] = self.lnk_link config[newkey] = self.lnk_link
else: else:
config[newkey] = self.lnk_nolink config[newkey] = self.lnk_nolink
del config[key] del config[old_key]
self._log.warn('deprecated \"link_by_default\"') self._log.warn('deprecated \"link_by_default\"')
self._dirty = True self._dirty = True
self._dirty_deprecated = True self._dirty_deprecated = True
def _fix_deprecated_dotfile_link(self, yamldict): def _fix_deprecated_dotfile_link(self, yamldict):
"""fix deprecated link in dotfiles""" """fix deprecated link in dotfiles"""
old_key = 'link_children'
if self.key_dotfiles not in yamldict: if self.key_dotfiles not in yamldict:
return return
if not yamldict[self.key_dotfiles]: if not yamldict[self.key_dotfiles]:
@@ -954,14 +954,14 @@ class CfgYaml:
self._dirty_deprecated = True self._dirty_deprecated = True
self._log.warn('deprecated \"link\" value') self._log.warn('deprecated \"link\" value')
elif self.key_dotfile_link_children in dotfile and \ elif old_key in dotfile and \
type(dotfile[self.key_dotfile_link_children]) is bool: type(dotfile[old_key]) is bool:
# patch link_children: <bool> # patch link_children: <bool>
cur = dotfile[self.key_dotfile_link_children] cur = dotfile[old_key]
new = self.lnk_nolink new = self.lnk_nolink
if cur: if cur:
new = self.lnk_children new = self.lnk_children
del dotfile[self.key_dotfile_link_children] del dotfile[old_key]
dotfile[self.key_dotfile_link] = new dotfile[self.key_dotfile_link] = new
self._dirty = True self._dirty = True
self._dirty_deprecated = True self._dirty_deprecated = True