From f6e31a7cf0b307cd6c548dcc1d8497b398be40db Mon Sep 17 00:00:00 2001 From: Mattia Almansi Date: Thu, 26 Sep 2024 12:45:43 +0200 Subject: [PATCH] use new url (#189) * use beta url * use right url --- scripts/validate-filenames.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/validate-filenames.py b/scripts/validate-filenames.py index 392af24e..5d19d495 100644 --- a/scripts/validate-filenames.py +++ b/scripts/validate-filenames.py @@ -40,7 +40,7 @@ "variability", ) -API_URL = "https://cds.climate.copernicus.eu/api/v2" +API_URL = "https://cds.climate.copernicus.eu/api/catalogue/v1/collections" def main(paths: list[Path]) -> None: @@ -50,7 +50,7 @@ def main(paths: list[Path]) -> None: assert len(segments) == 4, f"{path=!s}: Invalid {path.name=}" ( data_type, - dataset_id, + collection_id, assessment_category, question_number, ) = segments @@ -64,10 +64,13 @@ def main(paths: list[Path]) -> None: assert folder in path.parts[folder_index], f"{path=!s}: Invalid {folder=}" # Check dataset ID - url = f"{API_URL}/resources/dataset/{dataset_id}" - assert ( - urllib.request.urlopen(url).getcode() == 200 - ), f"{path=!s}: Invalid {dataset_id=}" + url = "/".join([API_URL, collection_id]) + code = None + try: + code = urllib.request.urlopen(url).getcode() + except Exception: + pass + assert code == 200, f"{path=!s}: Invalid {collection_id=}" # Check assessment category assert (