Fix --tar argument handling in validate-modern.py (#12707)

Blue committed Mar 17, 2025 at 13:51 UTC cbc6694cf5712426918bd82569085e2fa2e1cefd
1 file changed +16 -10
distributions/validate-modern.py
+16 -10
@@ -65,7 +65,7 @@ def main(manifest: str, tar: str, compare_with_branch: str, repo_path: str, arm6
65 try:
66 if tar is not None:
67 with open(tar, 'rb') as fd:
68 - read_tar(tar, '<none>', fd, ARM64_ELF_MAGIC if arm64 else X64_ELF_MAGIC)
68 + read_tar(None, fd, ARM64_ELF_MAGIC if arm64 else X64_ELF_MAGIC)
69 else:
70 if manifest is None:
71 raise RuntimeError('Either --tar or --manifest is required')
@@ -127,7 +127,7 @@ def main(manifest: str, tar: str, compare_with_branch: str, repo_path: str, arm6
127 if default_entries != 1:
128 error(e, 'Found no default distribution' if default_entries == 0 else 'Found multiple default distributions')
129
130 - report_status_on_pr(manifest)
130 + report_status_on_pr(manifest)
131
132 except:
133 if debug:
@@ -480,20 +480,26 @@ def read_url(url: dict, elf_magic):
480 warning(url, f'Tar format not supported by WSL1: {tar_format}')
481
482 def error(node, message: str):
483 - global errors
483 + if node is None:
484 + click.secho(f'Error: {message}', fg='red')
485 + else:
486 + global errors
487
485 - line = jsoncfg.node_location(node).line
486 - click.secho(f'Error on line {line}: {message}', fg='red')
488 + line = jsoncfg.node_location(node).line
489 + click.secho(f'Error on line {line}: {message}', fg='red')
490
488 - errors[line] = errors.get(line, []) + [message]
491 + errors[line] = errors.get(line, []) + [message]
492
493 def warning(node, message: str):
491 - global warnings
494 + if node is None:
495 + click.secho(f'Error: {message}', fg='red')
496 + else:
497 + global warnings
498
493 - line = jsoncfg.node_location(node).line
494 - click.secho(f'Warning on line {line}: {message}', fg='yellow')
499 + line = jsoncfg.node_location(node).line
500 + click.secho(f'Warning on line {line}: {message}', fg='yellow')
501
496 - warnings[line] = warnings.get(line, []) + [message]
502 + warnings[line] = warnings.get(line, []) + [message]
503
504 if __name__ == "__main__":
505 main()
\ No newline at end of file