From d26266e1f399fbd5aa3d1cbdea7014655bc4a169 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Sun, 24 Sep 2023 20:30:04 +0200 Subject: [PATCH] Pass subtags errors as warnings only --- catalog_linter.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/catalog_linter.py b/catalog_linter.py index acd345a..9ba6689 100755 --- a/catalog_linter.py +++ b/catalog_linter.py @@ -38,7 +38,7 @@ def validate_schema() -> Generator[str, None, None]: yield f"at .{'.'.join(error.path)}: {error.message}" -def check_app(app: str, infos: Dict[str, Any]) -> Generator[str, None, None]: +def check_app(app: str, infos: Dict[str, Any]) -> Generator[Tuple[str, bool], None, None]: if "state" not in infos: yield "state is missing" return @@ -48,27 +48,27 @@ def check_app(app: str, infos: Dict[str, Any]) -> Generator[str, None, None]: repo_name = infos.get("url", "").split("/")[-1] if repo_name != f"{app}_ynh": - yield f"repo name should be {app}_ynh, not in {repo_name}" + yield f"repo name should be {app}_ynh, not in {repo_name}", True antifeatures = infos.get("antifeatures", []) for antifeature in antifeatures: if antifeature not in get_antifeatures(): - yield f"unknown antifeature {antifeature}" + yield f"unknown antifeature {antifeature}", True category = infos.get("category") if not category: - yield "category is missing" + yield "category is missing", True else: if category not in get_categories(): - yield f"unknown category {category}" + yield f"unknown category {category}", True subtags = infos.get("subtags", []) for subtag in subtags: - if subtag not in get_categories()[category].get("subtags", []): - yield f"unknown subtag {category} / {subtag}" + if subtag not in get_categories().get(category, {}).get("subtags", []): + yield f"unknown subtag {category} / {subtag}", False -def check_all_apps() -> Generator[Tuple[str, List[str]], None, None]: +def check_all_apps() -> Generator[Tuple[str, List[Tuple[str, bool]]], None, None]: for app, info in get_catalog().items(): errors = list(check_app(app, info)) if errors: @@ -88,10 +88,12 @@ def main() -> None: print() for app, errors in check_all_apps(): - has_errors = True print(f"{app}:") - for error in errors: - print(f" - {error}") + for error, is_fatal in errors: + if is_fatal: + has_errors = True + level = "error" if is_fatal else "warning" + print(f" - {level}: {error}") if has_errors: sys.exit(1)