Skip to content

Commit

Permalink
tools/dashboard: iterate through args only when they are provided
Browse files Browse the repository at this point in the history
Internal-tag: [#46111]
Signed-off-by: Pawel Czarnecki <[email protected]>
  • Loading branch information
lpawelcz committed Dec 11, 2023
1 parent 4161ee4 commit f68952a
Showing 1 changed file with 34 additions and 28 deletions.
62 changes: 34 additions & 28 deletions xls/tools/dashboard/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,22 @@ def tuple_of_three(string: str) -> Tuple[str, str, str]:
def parse_args_to_dict(args) -> Sequence[TestData]:
args_dict = dict()

for test, parser in args.parser:
if test not in args_dict:
args_dict[test] = TestData(test)
args_dict[test].output_parsers += [OutputParserData(parser)]

for test, parser, file in args.file:
if test not in args_dict:
args_dict[test] = TestData(test)
args_dict[test].file_parsers += [FileParserData(parser, file)]
if args.parser is not None:
for test, parser in args.parser:
if test not in args_dict:
args_dict[test] = TestData(test)
args_dict[test].output_parsers += [OutputParserData(parser)]

if args.file is not None:
for test, parser, file in args.file:
if test not in args_dict:
args_dict[test] = TestData(test)
args_dict[test].file_parsers += [FileParserData(parser, file)]

data_parsers = []
for file, parser in args.data:
data_parsers += [FileParserData(parser, file)]
if args.data is not None:
for file, parser in args.data:
data_parsers += [FileParserData(parser, file)]

return args_dict.values(), data_parsers

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

for _, parser in args.parser:
parser_path = Path(parser)
if not parser_path.exists():
raise FileNotFoundError(f"Output parser {str(parser_path)} does not exist")

for _, parser, _ in args.file:
parser_path = Path(parser)
if not parser_path.exists():
raise FileNotFoundError(f"File parser {str(parser_path)} does not exist")

for file, parser in args.data:
parser_path = Path(parser)
if not parser_path.exists():
raise FileNotFoundError(f"Data file parser {str(parser_path)} does not exist")
file_path = Path(parser)
if not file_path.exists():
raise FileNotFoundError(f"Data file {str(file_path)} does not exist")
if args.parser is not None:
for _, parser in args.parser:
parser_path = Path(parser)
if not parser_path.exists():
raise FileNotFoundError(f"Output parser {str(parser_path)} does not exist")

if args.file is not None:
for _, parser, _ in args.file:
parser_path = Path(parser)
if not parser_path.exists():
raise FileNotFoundError(f"File parser {str(parser_path)} does not exist")

if args.data is not None:
for file, parser in args.data:
parser_path = Path(parser)
if not parser_path.exists():
raise FileNotFoundError(f"Data file parser {str(parser_path)} does not exist")
file_path = Path(parser)
if not file_path.exists():
raise FileNotFoundError(f"Data file {str(file_path)} does not exist")


if __name__ == "__main__":
Expand Down

0 comments on commit f68952a

Please sign in to comment.