1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-11 22:24:01 +00:00
This commit is contained in:
deadc0de6
2021-11-19 12:04:26 +01:00
parent d40e7819dc
commit 01fd7688d4

View File

@@ -106,8 +106,8 @@ class CfgYaml:
""" """
config parser config parser
@path: config file path @path: config file path
@profile: the selected profile @profile: the selected profile names
@addprofiles: included profiles @addprofiles: included profiles names (list)
@reloading: true when reloading @reloading: true when reloading
@debug: debug flag @debug: debug flag
""" """
@@ -140,6 +140,11 @@ class CfgYaml:
self._dbg(err) self._dbg(err)
raise YamlException(err) raise YamlException(err)
self._dbg('START of config parsing')
self._dbg('reloading: {}'.format(reloading))
self._dbg('profile: {}'.format(profile))
self._dbg('included profiles: {}'.format(','.join(self._inc_profiles)))
self._yaml_dict = self._load_yaml(self._path) self._yaml_dict = self._load_yaml(self._path)
# live patch deprecated entries # live patch deprecated entries
self._fix_deprecated(self._yaml_dict) self._fix_deprecated(self._yaml_dict)
@@ -189,7 +194,8 @@ class CfgYaml:
# include the profile's variables/dynvariables last # include the profile's variables/dynvariables last
# as it overwrites existing ones # as it overwrites existing ones
self._inc_profiles, pvar, pdvar = self._get_profile_included_vars() incpro, pvar, pdvar = self._get_profile_included_vars()
self._inc_profiles = uniq_list(self._inc_profiles + incpro)
self._add_variables(pvar, prio=True) self._add_variables(pvar, prio=True)
self._add_variables(pdvar, shell=True, prio=True) self._add_variables(pdvar, shell=True, prio=True)
self._profilevarskeys.extend(pvar.keys()) self._profilevarskeys.extend(pvar.keys())
@@ -267,6 +273,7 @@ class CfgYaml:
if self._debug: if self._debug:
self._dbg('########### {} ###########'.format('final config')) self._dbg('########### {} ###########'.format('final config'))
self._debug_entries() self._debug_entries()
self._dbg('END of config parsing')
######################################################## ########################################################
# public methods # public methods
@@ -970,6 +977,8 @@ class CfgYaml:
"""import config from path""" """import config from path"""
if self._debug: if self._debug:
self._dbg('import config from {}'.format(path)) self._dbg('import config from {}'.format(path))
self._dbg('profile: {}'.format(self._profile))
self._dbg('included profiles: {}'.format(self._inc_profiles))
sub = CfgYaml(path, profile=self._profile, sub = CfgYaml(path, profile=self._profile,
addprofiles=self._inc_profiles, addprofiles=self._inc_profiles,
debug=self._debug) debug=self._debug)
@@ -1128,7 +1137,7 @@ class CfgYaml:
"""load a yaml file to a dict""" """load a yaml file to a dict"""
content = {} content = {}
if self._debug: if self._debug:
self._dbg('----------start:{}----------'.format(path)) self._dbg('----------dump:{}----------'.format(path))
cfg = '\n' cfg = '\n'
with open(path, 'r', encoding='utf8') as file: with open(path, 'r', encoding='utf8') as file:
for line in file: for line in file:
@@ -1272,6 +1281,8 @@ class CfgYaml:
pro = self.profiles.get(self._profile, []) pro = self.profiles.get(self._profile, [])
if pro: if pro:
pdfs = list(pro.get(self.key_profile_dotfiles, [])) pdfs = list(pro.get(self.key_profile_dotfiles, []))
# and any included profiles
for addpro in self._inc_profiles: for addpro in self._inc_profiles:
pro = self.profiles.get(addpro, []) pro = self.profiles.get(addpro, [])
if not pro: if not pro:
@@ -1280,6 +1291,7 @@ class CfgYaml:
pdfs.extend(pdfsalt) pdfs.extend(pdfsalt)
pdfs = uniq_list(pdfs) pdfs = uniq_list(pdfs)
# if ALL is defined
if self.key_all not in pdfs: if self.key_all not in pdfs:
# take a subset of the dotfiles # take a subset of the dotfiles
newdotfiles = {} newdotfiles = {}