move spells to folder

This commit is contained in:
Brad Laney committed 2020-08-04 07:07:01 +00:00
1 parent 86c2ff401f
commit bcd9365c27
546 files changed
+17864

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
# THIS FILE SIMPLY LOADS THE YAML FILE INTO PYYAML AND THEN SPITS IT BACK OUT
# TO CLEAN UP AND ORDER ALL THE YAML
import yaml
import glob
import os
def main():
# change directory to the data directory
os.chdir('../data/')
# gets all files with a yaml extension in the directory
yfiles = []
for file in glob.glob("spells.yaml"):
yfiles.append(file)
yfiles.sort()
print("Going to clean up the following files: {}".format(yfiles))
for x in yfiles:
with open(x, 'r', encoding="utf8") as r:
data = yaml.full_load(r)
for m in data["spell"]:
print(m["name"])
part = yaml.safe_dump(m, allow_unicode=True)
with open(os.path.join("spells", m["name"].lower() + ".yaml"), 'w', encoding="utf8") as f:
f.write(part)
print("\tDone.")
if __name__ == "__main__":
main()