config parser @path: config file path @profile: the selected profile names @addprofiles: included profiles names (list) @reloading: true when reloading @imported_configs: paths of config files that have been imported so far @debug: debug flag
(self, path, profile=None, addprofiles=None,
reloading=False, debug=False, imported_configs=None,
fail_on_error=True)
| 115 | top_entries = [key_dotfiles, key_settings, key_profiles] |
| 116 | |
| 117 | def __init__(self, path, profile=None, addprofiles=None, |
| 118 | reloading=False, debug=False, imported_configs=None, |
| 119 | fail_on_error=True): |
| 120 | """ |
| 121 | config parser |
| 122 | @path: config file path |
| 123 | @profile: the selected profile names |
| 124 | @addprofiles: included profiles names (list) |
| 125 | @reloading: true when reloading |
| 126 | @imported_configs: paths of config files that have been imported so far |
| 127 | @debug: debug flag |
| 128 | """ |
| 129 | self._path = os.path.abspath(path) |
| 130 | self._profile = profile |
| 131 | self._reloading = reloading |
| 132 | self._debug = debug |
| 133 | self._log = Logger(debug=self._debug) |
| 134 | # config format |
| 135 | self._config_format = 'yaml' |
| 136 | # config needs to be written |
| 137 | self._dirty = False |
| 138 | # indicates the config has been updated |
| 139 | self._dirty_deprecated = False |
| 140 | # profile variables |
| 141 | self._profilevarskeys = [] |
| 142 | # included profiles |
| 143 | self._inc_profiles = addprofiles or [] |
| 144 | # imported configs |
| 145 | self.imported_configs = imported_configs or [] |
| 146 | |
| 147 | # init the dictionaries |
| 148 | self.settings = {} |
| 149 | self.dotfiles = {} |
| 150 | self.profiles = {} |
| 151 | self.actions = {} |
| 152 | self.trans_install = {} |
| 153 | self.trans_update = {} |
| 154 | self.variables = {} |
| 155 | |
| 156 | if not os.path.exists(self._path): |
| 157 | err = f'invalid config path: \"{path}\"' |
| 158 | if self._debug: |
| 159 | self._dbg(err) |
| 160 | raise YamlException(err) |
| 161 | |
| 162 | self._dbg('START of config parsing') |
| 163 | self._dbg(f'reloading: {reloading}') |
| 164 | self._dbg(f'profile: {profile}') |
| 165 | pfs = ','.join(self._inc_profiles) |
| 166 | self._dbg(f'included profiles: {pfs}') |
| 167 | |
| 168 | self._yaml_dict = self._load_yaml(self._path) |
| 169 | # live patch deprecated entries |
| 170 | self._fix_deprecated(self._yaml_dict) |
| 171 | # validate content |
| 172 | self._validate(self._yaml_dict, fail_on_error) |
| 173 | |
| 174 | ################################################## |
nothing calls this directly
no test coverage detected