Skip to content

Commit

Permalink
use new url (#189)
Browse files Browse the repository at this point in the history
* use beta url

* use right url
  • Loading branch information
malmans2 authored Sep 26, 2024
1 parent 4cd1f10 commit f6e31a7
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions scripts/validate-filenames.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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 (
Expand Down

0 comments on commit f6e31a7

Please sign in to comment.