From e9c31c035ba7e2e0cbb764c9c8a403c4e88e4614 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 26 Feb 2024 09:59:08 +0100 Subject: [PATCH] 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. --- stages/org.osbuild.coreos.platform | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/stages/org.osbuild.coreos.platform b/stages/org.osbuild.coreos.platform index d2b44d8b..51fcc824 100755 --- a/stages/org.osbuild.coreos.platform +++ b/stages/org.osbuild.coreos.platform @@ -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):