mirror of
https://gitlab.com/jrmiller82/pathfinder-2-sqlite.git
synced 2026-10-12 22:29:44 -04:00
MAJOR DIRECTORY OVERHAUL
This commit is contained in:
1 parent
71ed03b165
commit
34ef5a6025
138 files changed
+48
-6
No files matched your search
@@ -0,0 +1,53 @@
|
||||
# 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("*.yaml"):
|
||||
yfiles.append(file)
|
||||
|
||||
yfiles.sort()
|
||||
print("Going to clean up the following files: {}".format(yfiles))
|
||||
|
||||
for x in yfiles:
|
||||
print("Doing: {}".format(x))
|
||||
with open(x, 'r') as r:
|
||||
data = yaml.full_load(r)
|
||||
if x == "feats.yaml":
|
||||
for i in data['feat']:
|
||||
# This is to clean out smart quotes that made it into the
|
||||
# yaml file so it matches the requirements.yaml
|
||||
if i['requirement'] != None:
|
||||
# print("Before: {}".format(i['requirement']))
|
||||
i['requirement'] = i['requirement'].replace('’', "'")
|
||||
# print("After: {}".format(i['requirement']))
|
||||
if i['trigger'] != None:
|
||||
# print("Before: {}".format(i['trigger']))
|
||||
i['trigger'] = i['trigger'].replace('’', "'")
|
||||
# print("After: {}".format(i['trigger']))
|
||||
if x == "triggers.yaml":
|
||||
for i in data['trigger']:
|
||||
print(i)
|
||||
i = i.replace('’', "'")
|
||||
|
||||
|
||||
|
||||
final = yaml.safe_dump(data, allow_unicode=True)
|
||||
with open(x, 'w') as f:
|
||||
f.write(final)
|
||||
print("\tDone.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
+2100
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,50 @@
|
||||
import yaml
|
||||
import pprint
|
||||
import os
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
standardize_monsters()
|
||||
|
||||
|
||||
def standardize_monsters():
|
||||
os.chdir('../data/')
|
||||
with open('monsters.yaml', 'r') as f:
|
||||
data = yaml.full_load(f)
|
||||
goodset = set()
|
||||
for i in data['monsters']:
|
||||
deletekeys = []
|
||||
for k, v in i.items():
|
||||
# print("Key:{}\tValue:{}".format(k,v))
|
||||
if v == None:
|
||||
# print("Deleting key: {} from {}".format(k, i['name']))
|
||||
deletekeys.append(k)
|
||||
else:
|
||||
goodset.add(k)
|
||||
# got to do it this way or your get a runtime error for changing the
|
||||
# index mid iteration
|
||||
for z in deletekeys:
|
||||
del (i[z])
|
||||
# print(goodset)
|
||||
|
||||
for i in data['monsters']:
|
||||
for k in goodset:
|
||||
if k not in i:
|
||||
# print("Adding field {} to {}".format(k, i['name']))
|
||||
i[k] = None
|
||||
|
||||
final = yaml.safe_dump(data, allow_unicode=True)
|
||||
with open('monsters.yaml', 'w') as f:
|
||||
f.write(final)
|
||||
|
||||
# pprint.pprint(data['monsters'][0])
|
||||
|
||||
# print(data['monsters'][0].keys())
|
||||
|
||||
# for key, value in data['monsters'][0]:
|
||||
# print("Key:{}\tValue:{}".format(key,value))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,13 @@
|
||||
import html
|
||||
|
||||
def main():
|
||||
|
||||
# read in the file
|
||||
with open("../data/yaml/monsters.yaml", 'r') as content_file:
|
||||
content = content_file.read()
|
||||
# print(html.unescape(content))
|
||||
with open("../data/yaml/monsters-fixed.yaml", 'w') as outfile:
|
||||
outfile.write(html.unescape(content))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user