1
0
Fork 0
mirror of https://github.com/ldericher/fftcgtool synced 2025-01-15 15:02:59 +00:00

yaml Loader/Dumper

This commit is contained in:
Jörn-Michael Miehe 2021-08-16 04:01:39 +02:00
parent 18e1676576
commit eed07e4bb0

View file

@ -60,7 +60,7 @@ class Book:
# load pages.yml file # load pages.yml file
try: try:
with open("pages.yml", "r") as file: with open("pages.yml", "r") as file:
pages = yaml.load(file) pages = yaml.load(file, Loader=yaml.Loader)
except FileNotFoundError: except FileNotFoundError:
pages = {} pages = {}
@ -71,8 +71,8 @@ class Book:
page["image"].save(fn) page["image"].save(fn)
# add contents of image # add contents of image
pages[fn] = {} pages[fn] = {}
pages[fn]["cards"] = page["cards"] # [card.code for card in page["cards"]] pages[fn]["cards"] = page["cards"]
# update pages.yml file # update pages.yml file
with open("pages.yml", "w") as file: with open("pages.yml", "w") as file:
yaml.dump(pages, file) yaml.dump(pages, file, Dumper=yaml.Dumper)