Skip to content

Commit f68952a

Browse files
committed
tools/dashboard: iterate through args only when they are provided
Internal-tag: [#46111] Signed-off-by: Pawel Czarnecki <[email protected]>
1 parent 4161ee4 commit f68952a

File tree

1 file changed

+34
-28
lines changed

1 file changed

+34
-28
lines changed

xls/tools/dashboard/dashboard.py

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,22 @@ def tuple_of_three(string: str) -> Tuple[str, str, str]:
3737
def parse_args_to_dict(args) -> Sequence[TestData]:
3838
args_dict = dict()
3939

40-
for test, parser in args.parser:
41-
if test not in args_dict:
42-
args_dict[test] = TestData(test)
43-
args_dict[test].output_parsers += [OutputParserData(parser)]
44-
45-
for test, parser, file in args.file:
46-
if test not in args_dict:
47-
args_dict[test] = TestData(test)
48-
args_dict[test].file_parsers += [FileParserData(parser, file)]
40+
if args.parser is not None:
41+
for test, parser in args.parser:
42+
if test not in args_dict:
43+
args_dict[test] = TestData(test)
44+
args_dict[test].output_parsers += [OutputParserData(parser)]
45+
46+
if args.file is not None:
47+
for test, parser, file in args.file:
48+
if test not in args_dict:
49+
args_dict[test] = TestData(test)
50+
args_dict[test].file_parsers += [FileParserData(parser, file)]
4951

5052
data_parsers = []
51-
for file, parser in args.data:
52-
data_parsers += [FileParserData(parser, file)]
53+
if args.data is not None:
54+
for file, parser in args.data:
55+
data_parsers += [FileParserData(parser, file)]
5356

5457
return args_dict.values(), data_parsers
5558

@@ -75,23 +78,26 @@ def check_args(args) -> None:
7578
if output_dir.exists():
7679
raise FileExistsError(f"Output directory {str(output_dir)} exists")
7780

78-
for _, parser in args.parser:
79-
parser_path = Path(parser)
80-
if not parser_path.exists():
81-
raise FileNotFoundError(f"Output parser {str(parser_path)} does not exist")
82-
83-
for _, parser, _ in args.file:
84-
parser_path = Path(parser)
85-
if not parser_path.exists():
86-
raise FileNotFoundError(f"File parser {str(parser_path)} does not exist")
87-
88-
for file, parser in args.data:
89-
parser_path = Path(parser)
90-
if not parser_path.exists():
91-
raise FileNotFoundError(f"Data file parser {str(parser_path)} does not exist")
92-
file_path = Path(parser)
93-
if not file_path.exists():
94-
raise FileNotFoundError(f"Data file {str(file_path)} does not exist")
81+
if args.parser is not None:
82+
for _, parser in args.parser:
83+
parser_path = Path(parser)
84+
if not parser_path.exists():
85+
raise FileNotFoundError(f"Output parser {str(parser_path)} does not exist")
86+
87+
if args.file is not None:
88+
for _, parser, _ in args.file:
89+
parser_path = Path(parser)
90+
if not parser_path.exists():
91+
raise FileNotFoundError(f"File parser {str(parser_path)} does not exist")
92+
93+
if args.data is not None:
94+
for file, parser in args.data:
95+
parser_path = Path(parser)
96+
if not parser_path.exists():
97+
raise FileNotFoundError(f"Data file parser {str(parser_path)} does not exist")
98+
file_path = Path(parser)
99+
if not file_path.exists():
100+
raise FileNotFoundError(f"Data file {str(file_path)} does not exist")
95101

96102

97103
if __name__ == "__main__":

0 commit comments

Comments
 (0)