Skip to content

Commit

Permalink
seastar-json2code: use dict.get() when checking allowMultiple
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
tchaikov committed Feb 26, 2024
1 parent cb78f9e commit 3f534c7
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions scripts/seastar-json2code.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down

0 comments on commit 3f534c7

Please sign in to comment.