@samitouri / QOSAMI-WSL / commits / 7f45ed0d

Updated validate.py to optionally accept a specific distro (#9992)

* Updated validate.py to optionally accept a specific distro * Updated to include errors

Craig Loewen committed Apr 19, 2023 at 12:58 UTC 7f45ed0d0f36a613cd84fea3e60ef2d6d74fea30
1 file changed +9 -2
distributions/validate.py
+9 -2
@@ -61,7 +61,7 @@ def is_unique(collection: list):
61
62 if __name__ == "__main__":
63 if len(sys.argv) < 2:
64 - print(f'Usage: {sys.argv[0]} /path/to/file', file=sys.stderr)
64 + print(f'Usage: {sys.argv[0]} /path/to/file [distroName]', file=sys.stderr)
65 exit(1)
66
67 with open(sys.argv[1]) as fd:
@@ -70,8 +70,15 @@ if __name__ == "__main__":
70 distros = content['Distributions']
71 assert is_unique([e.get('StoreAppId') for e in distros if e])
72 assert is_unique([e.get('Name') for e in distros if e])
73 +
74 + if len(sys.argv) > 2:
75 + # Filter the distros to only the one we want to validate
76 + content = { "Distributions": [e for e in content['Distributions'] if e['Name'] == sys.argv[2]] }
77 + if not content['Distributions']:
78 + raise RuntimeError(f'No distro found for name {sys.argv[2]}')
79 +
80
81 for e in content['Distributions']:
82 validate_distro(e)
83
77 - print("All checks completed successfully")
\ No newline at end of file
84 + print("All checks completed successfully")