Skip to content

Commit 7c7d774

Browse files
Simplify cmd parsing logic
1 parent 80cb16c commit 7c7d774

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

ads/aqua/common/utils.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,12 +1114,16 @@ def parse_cmd_var(cmd_list: List[str]) -> dict:
11141114
"""Helper functions that parses a list into a key-value dictionary. The list contains keys separated by the prefix
11151115
'--' and the value of the key is the subsequent element.
11161116
"""
1117-
it = iter(cmd_list)
1118-
return {
1119-
key: next(it, None) if not key.startswith("--") else next(it, None)
1120-
for key in it
1121-
if key.startswith("--")
1122-
}
1117+
parsed_cmd = {}
1118+
1119+
for i, cmd in enumerate(cmd_list):
1120+
if cmd.startswith("--"):
1121+
if i + 1 < len(cmd_list) and not cmd_list[i + 1].startswith("--"):
1122+
parsed_cmd[cmd] = cmd_list[i + 1]
1123+
i += 1
1124+
else:
1125+
parsed_cmd[cmd] = None
1126+
return parsed_cmd
11231127

11241128

11251129
def validate_cmd_var(cmd_var: List[str], overrides: List[str]) -> List[str]:

0 commit comments

Comments
 (0)