Skip to content

Commit

Permalink
Comply with lint - rename var names in json mods logic to be more clear
Browse files Browse the repository at this point in the history
  • Loading branch information
sdsznsk committed Nov 1, 2023
1 parent 0c26ead commit 9d994e8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,16 @@ def bool_str(text):
with open(os.environ["GAME_MODS_JSON_FILE_PATH"]) as f:
json_mods = json.load(f)
allowed_keys = ["modId", "name", "version"]
for mod in json_mods:
assert "modId" in mod, f"Entry in GAME_MODS_JSON_FILE_PATH file does not contain modId: {mod}"
mod = {key: mod[key] for key in allowed_keys if key in mod} # Extract only valid config keys
config["game"]["mods"].append(mod)
for provided_mod in json_mods:
assert (
"modId" in provided_mod
), f"Entry in GAME_MODS_JSON_FILE_PATH file does not contain modId: {provided_mod}"
valid_mod = {
key: provided_mod[key]
for key in allowed_keys
if key in provided_mod
} # Extract only valid config keys
config["game"]["mods"].append(valid_mod)

f = open(CONFIG_GENERATED, "w")
json.dump(config, f, indent=4)
Expand Down

0 comments on commit 9d994e8

Please sign in to comment.