mirror of
https://github.com/correl/mtgsqlive.git
synced 2024-11-25 03:00:10 +00:00
v5 Structure Handling (#52)
This commit is contained in:
parent
13d2a09b7f
commit
26650c1a05
1 changed files with 12 additions and 4 deletions
|
@ -55,6 +55,10 @@ def execute(input_file, output_file, extras=False) -> None:
|
||||||
|
|
||||||
|
|
||||||
def getVersion(json_data: Dict) -> str:
|
def getVersion(json_data: Dict) -> str:
|
||||||
|
if "meta" in json_data:
|
||||||
|
if "version" in json_data["meta"]:
|
||||||
|
return json_data["meta"]["version"]
|
||||||
|
else:
|
||||||
for set_code, set_data in json_data.items():
|
for set_code, set_data in json_data.items():
|
||||||
if "meta" in set_data:
|
if "meta" in set_data:
|
||||||
if "version" in set_data["meta"]:
|
if "version" in set_data["meta"]:
|
||||||
|
@ -192,6 +196,8 @@ def generate_sql_schema(json_data: Dict, output_file: Dict, distro: str) -> str:
|
||||||
"cards": ["borderColor", "frameEffect", "frameVersion", "layout", "rarity"],
|
"cards": ["borderColor", "frameEffect", "frameVersion", "layout", "rarity"],
|
||||||
"tokens": ["borderColor", "layout"],
|
"tokens": ["borderColor", "layout"],
|
||||||
}
|
}
|
||||||
|
if "data" in json_data:
|
||||||
|
json_data = json_data["data"]
|
||||||
for setCode, setData in json_data.items():
|
for setCode, setData in json_data.items():
|
||||||
# loop through each set property
|
# loop through each set property
|
||||||
for setKey, setValue in setData.items():
|
for setKey, setValue in setData.items():
|
||||||
|
@ -377,6 +383,8 @@ def parse_and_import_cards(
|
||||||
:param output_file: Output info dictionary
|
:param output_file: Output info dictionary
|
||||||
"""
|
"""
|
||||||
LOGGER.info("Building sets")
|
LOGGER.info("Building sets")
|
||||||
|
if "data" in json_data:
|
||||||
|
json_data = json_data["data"]
|
||||||
for set_code, set_data in json_data.items():
|
for set_code, set_data in json_data.items():
|
||||||
# Handle set insertion
|
# Handle set insertion
|
||||||
LOGGER.info("Inserting set row for {}".format(set_code))
|
LOGGER.info("Inserting set row for {}".format(set_code))
|
||||||
|
|
Loading…
Reference in a new issue