From e02e5fb9cbb6a67de7f5006774614c52c566860a Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 18 Dec 2023 19:00:53 +0100 Subject: [PATCH] Improve linter to also check notworking apps and graveyard entries --- catalog_linter.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/catalog_linter.py b/catalog_linter.py index 3c5453e..3657180 100755 --- a/catalog_linter.py +++ b/catalog_linter.py @@ -37,6 +37,12 @@ def get_wishlist() -> Dict[str, Dict[str, str]]: return toml.load(wishlist_path) +@cache +def get_graveyard() -> Dict[str, Dict[str, str]]: + wishlist_path = APPS_ROOT / "graveyard.toml" + return toml.load(wishlist_path) + + def validate_schema() -> Generator[str, None, None]: with open(APPS_ROOT / "schemas" / "apps.toml.schema.json", encoding="utf-8") as file: apps_catalog_schema = json.load(file) @@ -50,9 +56,6 @@ def check_app(app: str, infos: Dict[str, Any]) -> Generator[Tuple[str, bool], No yield "state is missing", True return - if infos["state"] != "working": - return - # validate that the app is not (anymore?) in the wishlist # we use fuzzy matching because the id in catalog may not be the same exact id as in the wishlist # some entries are ignore-hard-coded, because e.g. radarr an readarr are really different apps... @@ -66,6 +69,14 @@ def check_app(app: str, infos: Dict[str, Any]) -> Generator[Tuple[str, bool], No if wishlist_matches: yield f"app seems to be listed in wishlist: {wishlist_matches}", True + graveyard_matches = [ + grave + for grave in get_graveyard() + if SequenceMatcher(None, app, grave).ratio() > 0.9 + ] + if graveyard_matches: + yield f"app seems to be listed in graveyard: {graveyard_matches}", True + 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}", True