1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-06 03:13:03 +00:00

fix dotfile trans

This commit is contained in:
deadc0de6
2023-09-24 14:20:31 +02:00
committed by deadc0de
parent 11bfd0a838
commit 0fa4c6110f
4 changed files with 16 additions and 22 deletions

View File

@@ -816,9 +816,6 @@ class CfgYaml:
new = {}
for k, val in dotfiles.items():
# fix depreacated trans
self._fix_deprecated_trans_in_dict(val)
if self.key_dotfile_src not in val:
# add 'src' as key' if not present
val[self.key_dotfile_src] = k
@@ -1193,7 +1190,7 @@ class CfgYaml:
if old_key in yamldic:
yamldic[old_key] = yamldic[new_key]
del yamldic[old_key]
msg = f'\"{old_key}\" is deprecated, '
msg = f'deprecated \"{old_key}\", '
msg += f', updated to {new_key}\"'
self._log.warn(msg)
self._dirty = True
@@ -1225,12 +1222,13 @@ class CfgYaml:
def _fix_deprecated_trans(self, yamldict):
"""fix deprecated trans key"""
if self.key_settings not in yamldict:
return
if not yamldict[self.key_settings]:
return
config = yamldict[self.key_settings]
self._fix_deprecated_trans_in_dict(config)
# top ones
self._fix_deprecated_trans_in_dict(yamldict)
# dotfiles ones
if self.key_dotfiles in yamldict and yamldict[self.key_dotfiles]:
config = yamldict[self.key_dotfiles]
for _, val in config.items():
self._fix_deprecated_trans_in_dict(val)
def _fix_deprecated_link_by_default(self, yamldict):
"""fix deprecated link_by_default"""

View File

@@ -540,8 +540,8 @@ def cmd_importer(opts):
import_as=opts.import_as,
import_link=opts.import_link,
import_mode=opts.import_mode,
import_trans_install=opts.import_transr,
import_trans_update=opts.import_transw)
trans_install=opts.import_trans_install,
trans_update=opts.import_trans_update)
if tmpret < 0:
ret = False
elif tmpret > 0:

View File

@@ -95,13 +95,9 @@ class Dotfile(DictParser):
def _adjust_yaml_keys(cls, value):
"""patch dict"""
value['noempty'] = value.get(cls.key_noempty, False)
value['trans_install'] = value.get(cls.key_trans_install)
value['trans_update'] = value.get(cls.key_trans_update)
value['template'] = value.get(cls.key_template, True)
# remove old entries
value.pop(cls.key_noempty, None)
value.pop(cls.key_trans_install, None)
value.pop(cls.key_trans_update, None)
return value
def __eq__(self, other):

View File

@@ -75,8 +75,8 @@ class Importer:
def import_path(self, path, import_as=None,
import_link=LinkTypes.NOLINK,
import_mode=False,
import_trans_install="",
import_trans_update=""):
trans_install="",
trans_update=""):
"""
import a dotfile pointed by path
returns:
@@ -93,10 +93,10 @@ class Importer:
# check trans_update if any
trans_install = None
trans_update = None
if import_trans_install:
trans_install = self.conf.get_trans_install(import_trans_install)
if import_trans_update:
trans_update = self.conf.get_trans_update(import_trans_update)
if trans_install:
trans_install = self.conf.get_trans_install(trans_install)
if trans_update:
trans_update = self.conf.get_trans_update(trans_update)
return self._import(path, import_as=import_as,
import_link=import_link,