stages: tweak process_platforms_json to be slightly shorter

With the test the helper can now be slightly simplified. Because
we only have two results it seems easier to just use them directly
than to store them in an intermediate result struct.
This commit is contained in:
Michael Vogt 2024-02-26 09:59:08 +01:00
parent 6cc7309890
commit e9c31c035b

View file

@ -70,17 +70,12 @@ def generate_console_settings_file(console_settings, file_path):
def process_platforms_json(json_file_path, platform):
keys = ["grub_commands", "kernel_arguments"]
result = {}
with open(json_file_path, 'r', encoding="utf8") as file:
data = json.load(file)
if platform in data:
for key in keys:
if key in data[platform]:
result[key] = data[platform][key]
return result.get("grub_commands", []),\
result.get("kernel_arguments", [])
with open(json_file_path, 'r', encoding="utf8") as fp:
data = json.load(fp)
platform = data.get(platform, {})
grub_cmds = platform.get("grub_commands", [])
kernel_args = platform.get("kernel_arguments", [])
return grub_cmds, kernel_args
def main(paths, options):