save this instance and return True if saved
(self)
| 516 | return True |
| 517 | |
| 518 | def save(self): |
| 519 | """save this instance and return True if saved""" |
| 520 | if not self._dirty: |
| 521 | return False |
| 522 | |
| 523 | content = self._prepare_to_save(self._yaml_dict) |
| 524 | |
| 525 | if self._dirty_deprecated: |
| 526 | # add minversion |
| 527 | settings = content[self.key_settings] |
| 528 | settings[self.key_settings_minversion] = VERSION |
| 529 | |
| 530 | # save to file |
| 531 | if self._debug: |
| 532 | self._dbg(f'saving to {self._path}') |
| 533 | try: |
| 534 | with open(self._path, 'w', encoding='utf8') as file: |
| 535 | self._yaml_dump(content, file, fmt=self._config_format) |
| 536 | except Exception as exc: |
| 537 | self._log.err(exc) |
| 538 | err = f'error saving config: {self._path}' |
| 539 | raise YamlException(err) from exc |
| 540 | |
| 541 | if self._dirty_deprecated: |
| 542 | warn = 'your config contained deprecated entries' |
| 543 | warn += ' and was updated' |
| 544 | self._log.warn(warn) |
| 545 | |
| 546 | self._dirty = False |
| 547 | return True |
| 548 | |
| 549 | def dump(self): |
| 550 | """dump the config dictionary""" |
no test coverage detected