| 191 | return type_x == type_y |
| 192 | |
| 193 | def load(self): |
| 194 | filename = os.path.abspath(self.filename) |
| 195 | secretsfn = os.path.abspath(self.secretsfn) |
| 196 | if not os.path.isfile(filename): |
| 197 | log.debug(f'Settings: config="{filename}" secrets="{secretsfn}" created') |
| 198 | self.save() |
| 199 | return |
| 200 | self.data = readfile(filename, lock=True, as_type="dict") |
| 201 | self.secrets = readfile(secretsfn, lock=True, as_type="dict") |
| 202 | if self.data.get('quicksettings') is not None and self.data.get('quicksettings_list') is None: |
| 203 | self.data['quicksettings_list'] = [i.strip() for i in self.data.get('quicksettings', '').split(',')] |
| 204 | unknown_settings = [] |
| 205 | for k, v in self.data.items(): |
| 206 | info = self.data_labels.get(k, None) |
| 207 | if info is not None: |
| 208 | if not info.validate(k, v): |
| 209 | self.data[k] = info.default |
| 210 | if info is not None and not self.same_type(info.default, v): |
| 211 | log.warning(f"Setting validation: {k}={v} ({type(v).__name__} expected={type(info.default).__name__})") |
| 212 | self.data[k] = info.default |
| 213 | if info is None and k not in compatibility_opts and not k.startswith('uiux_'): |
| 214 | unknown_settings.append(k) |
| 215 | if len(unknown_settings) > 0: |
| 216 | log.warning(f"Setting validation: unknown={unknown_settings}") |
| 217 | |
| 218 | def onchange(self, key, func: Callable, call=True): |
| 219 | item = self.data_labels.get(key) |