From 7f45ed0d0f36a613cd84fea3e60ef2d6d74fea30 Mon Sep 17 00:00:00 2001 From: Craig Loewen Date: Wed, 19 Apr 2023 12:58:45 -0400 Subject: [PATCH] Updated validate.py to optionally accept a specific distro (#9992) * Updated validate.py to optionally accept a specific distro * Updated to include errors --- distributions/validate.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/distributions/validate.py b/distributions/validate.py index 1f2fa51..5715af8 100644 --- a/distributions/validate.py +++ b/distributions/validate.py @@ -61,7 +61,7 @@ def is_unique(collection: list): if __name__ == "__main__": if len(sys.argv) < 2: - print(f'Usage: {sys.argv[0]} /path/to/file', file=sys.stderr) + print(f'Usage: {sys.argv[0]} /path/to/file [distroName]', file=sys.stderr) exit(1) with open(sys.argv[1]) as fd: @@ -70,8 +70,15 @@ if __name__ == "__main__": distros = content['Distributions'] assert is_unique([e.get('StoreAppId') for e in distros if e]) assert is_unique([e.get('Name') for e in distros if e]) + + if len(sys.argv) > 2: + # Filter the distros to only the one we want to validate + content = { "Distributions": [e for e in content['Distributions'] if e['Name'] == sys.argv[2]] } + if not content['Distributions']: + raise RuntimeError(f'No distro found for name {sys.argv[2]}') + for e in content['Distributions']: validate_distro(e) - print("All checks completed successfully") \ No newline at end of file + print("All checks completed successfully")