def save_server(self, server_id, data=None, notes=None):
if not data:
data = self.data[server_id]
if not notes:
notes = self.notes[server_id]
try:
if not os.path.exists("data/{}".format(server_id)):
self.add_server(server_id)
with open("data/{}/config.yml".format(server_id), "w") as config_fh:
yaml.safe_dump(data["config"], config_fh)
with open("data/{}/notes.yml".format(server_id), "w") as notes_fh:
yaml.safe_dump(self.serialise_notes(notes), notes_fh)
with open("data/{}/sections.yml".format(server_id), "w") as sections_fh:
yaml.safe_dump(self.serialise_sections(data["sections"]), sections_fh)
except Exception:
log.exception("Error saving server '{}'".format(server_id))
评论列表
文章目录