MCPcopy
hub / github.com/deadc0de6/dotdrop / save

Method save

dotdrop/cfg_yaml.py:518–547  ·  view source on GitHub ↗

save this instance and return True if saved

(self)

Source from the content-addressed store, hash-verified

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"""

Callers 3

cmd_importerFunction · 0.45
cmd_removeFunction · 0.45
mainFunction · 0.45

Calls 6

_prepare_to_saveMethod · 0.95
_dbgMethod · 0.95
_yaml_dumpMethod · 0.95
YamlExceptionClass · 0.90
errMethod · 0.80
warnMethod · 0.80

Tested by

no test coverage detected