From 3f534c77d7b47398e582610e03ad08214fce32be Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 26 Feb 2024 10:30:13 +0800 Subject: [PATCH] seastar-json2code: use dict.get() when checking allowMultiple simpler this way. it also silences following warning: ``` visually indented line with same indent as next logical line [E129] ``` from pycodestyle, see also https://peps.python.org/pep-0008/#indentation. Signed-off-by: Kefu Chai --- scripts/seastar-json2code.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/scripts/seastar-json2code.py b/scripts/seastar-json2code.py index 7d2017bf34d..4f0a8c123eb 100755 --- a/scripts/seastar-json2code.py +++ b/scripts/seastar-json2code.py @@ -294,14 +294,13 @@ def add_operation(hfile, ccfile, path, oper): else: fprint(ccfile, "\n,") if is_url: - fprint(ccfile, '{', '"/', path_param , '", path_description::url_component_type::FIXED_STRING', '}') + component_type = 'FIXED_STRING' + elif get_parameter_by_name(oper, path_param).get("allowMultiple", + False): + component_type = 'PARAM_UNTIL_END_OF_PATH' else: - path_param_type = get_parameter_by_name(oper, path_param) - if ("allowMultiple" in path_param_type and - path_param_type["allowMultiple"]): - fprint(ccfile, '{', '"', path_param , '", path_description::url_component_type::PARAM_UNTIL_END_OF_PATH', '}') - else: - fprint(ccfile, '{', '"', path_param , '", path_description::url_component_type::PARAM', '}') + component_type = 'PARAM' + fprint(ccfile, f'{{"/{path_param}", path_description::url_component_type::{component_type}}}') fprint(ccfile, '}') fprint(ccfile, ',{') enum_definitions = ""