Skip to content
This repository has been archived by the owner on Nov 11, 2021. It is now read-only.

Commit

Permalink
Fixed array conversion from Valve's KV3 to JSON script
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasK33 committed Jan 30, 2021
1 parent bd8f2f7 commit 91d6ccc
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions scripts/vdacdefs2json.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,24 @@ def convert_entries_to_numerical(element: Union[str, dict, list, float, int]):
elif isinstance(element, list):
return [convert_entries_to_numerical(entry) for entry in element]

def convert_indexed_lists_to_non_indexed(element: Union[str, dict, list, float, int]):
if isinstance(element, dict):
keys = list(element.keys())
if len(keys) > 0 and keys[0] == "0":
element = list(element.values())
else:
for key, entry in element.items():
element[key] = convert_indexed_lists_to_non_indexed(entry)

return element

if isinstance(element, list):
return [convert_indexed_lists_to_non_indexed(el) for el in element]

return element

dacdefs = convert_entries_to_numerical(dacdefs)
dacdefs = convert_indexed_lists_to_non_indexed(dacdefs)

# Dump the parsed dict to a JSON file
with open(output_file_path, "w") as json_file:
Expand Down

0 comments on commit 91d6ccc

Please sign in to comment.