Add names to large data objects
This is so if you do a jq query like `.CHARACTERS[] | select(originally == "Mog")` you'll get their name in the data output.
This commit is contained in:
parent
82ff5f86f4
commit
1af6a89e6b
1 changed files with 4 additions and 2 deletions
6
main.py
6
main.py
|
@ -43,6 +43,7 @@ class Parser: # noqa: PLR0904
|
||||||
if "(Level " in line:
|
if "(Level " in line:
|
||||||
name = line.split(" (")[0]
|
name = line.split(" (")[0]
|
||||||
info["stats"]["level"] = int(line.split("(Level ")[1][:-1])
|
info["stats"]["level"] = int(line.split("(Level ")[1][:-1])
|
||||||
|
info["name"] = name
|
||||||
# Stat chart rows
|
# Stat chart rows
|
||||||
elif line.startswith("|"):
|
elif line.startswith("|"):
|
||||||
for stat in line[1:-1].split("|"):
|
for stat in line[1:-1].split("|"):
|
||||||
|
@ -144,6 +145,7 @@ class Parser: # noqa: PLR0904
|
||||||
# Name
|
# Name
|
||||||
if line[0:2].isdigit():
|
if line[0:2].isdigit():
|
||||||
name = line[4:]
|
name = line[4:]
|
||||||
|
info["name"] = name
|
||||||
|
|
||||||
# Stat chart rows: BCEX Version only
|
# Stat chart rows: BCEX Version only
|
||||||
elif line.startswith("|"):
|
elif line.startswith("|"):
|
||||||
|
@ -422,7 +424,7 @@ class Parser: # noqa: PLR0904
|
||||||
elif line.strip():
|
elif line.strip():
|
||||||
dance = line.strip()
|
dance = line.strip()
|
||||||
if dance not in result:
|
if dance not in result:
|
||||||
result[dance] = {}
|
result[dance] = {"name": dance}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -450,7 +452,7 @@ class Parser: # noqa: PLR0904
|
||||||
elif next_esper:
|
elif next_esper:
|
||||||
esper = line.strip()
|
esper = line.strip()
|
||||||
if esper not in result:
|
if esper not in result:
|
||||||
result[esper] = {"learnset": {}}
|
result[esper] = {"learnset": {}, "name": esper}
|
||||||
next_esper = False
|
next_esper = False
|
||||||
# Any line with ":" is a k=v we should just shove into the dict
|
# Any line with ":" is a k=v we should just shove into the dict
|
||||||
elif ": " in line:
|
elif ": " in line:
|
||||||
|
|
Loading…
Add table
Reference in a new issue