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

add ability to import to no profile with ALL

This commit is contained in:
deadc0de6
2022-09-03 08:44:47 +02:00
committed by deadc0de
parent 2ed28ceeda
commit 7974939e68
5 changed files with 180 additions and 15 deletions

View File

@@ -351,6 +351,8 @@ class CfgYaml:
"""
# create the profile if it doesn't exist
self._new_profile(profile_key)
if profile_key not in self.profiles:
return False
profile = self.profiles[profile_key]
# ensure profile dotfiles list is not None
@@ -724,6 +726,14 @@ class CfgYaml:
return profiles
new = {}
for k, val in profiles.items():
if k == self.key_all:
msg = f'\"{self.key_all}\" is a special profile name, '
msg += 'consider renaming to avoid any issue.'
self._log.warn(msg)
if not k:
msg = 'empty profile name'
self._log.warn(msg)
continue
if not val:
# no dotfiles
continue
@@ -1097,6 +1107,14 @@ class CfgYaml:
def _new_profile(self, key):
"""add a new profile if it doesn't exist"""
if key == self.key_all:
err = f'profile key \"{key}\" is reserved'
self._log.warn(err)
raise YamlException(err)
if not key:
err = 'empty profile key'
self._log.warn(err)
raise YamlException(err)
if key not in self.profiles.keys():
# update yaml_dict
self._yaml_dict[self.key_profiles][key] = {