def save(self):
"""Persist the chains to disk"""
try:
logger.debug("Backing up chains")
if os.path.exists(self._db):
shutil.copyfile(self._db, "{}.bak".format(self._db))
except Exception as e:
logger.exception("Failed to backup chains")
return
try:
logger.debug("Saving chains")
with open(self._db, 'w') as f:
f.write(yaml.safe_dump(self._tables,
default_flow_style=False, explicit_start=True))
except:
logger.exception("Failed to save chains")
评论列表
文章目录