Commit 63f5abe6 authored by Christophe Benz's avatar Christophe Benz
Browse files

Fix resolve function, rename exception

parent 51e8d6a9
Pipeline #185524 passed with stage
in 18 seconds
......@@ -31,10 +31,10 @@ log = logging.getLogger(__name__)
class NoDatasetReleaseError(ValueError):
class NoReleaseDefinedError(ValueError):
def __init__(self, dataset_code: str):
message = (f"Could not resolve latest release for dataset code {dataset_code!r} "
"because it does not define any release")
"because no release is defined for this dataset")
self.dataset_code = dataset_code
......@@ -134,17 +134,17 @@ def resolve_latest_release(dataset_code: str, releases_json) -> str:
If dataset_code references the "latest" release, replace the release code by the actual latest one.
if releases_json is None:
raise NoReleaseDefinedError(dataset_code)
dataset_code_prefix, release_code = parse_dataset_release(dataset_code)
if release_code != LATEST_RELEASE:
if release_code is None or release_code != LATEST_RELEASE:
return dataset_code
if releases_json is None:
raise NoDatasetReleaseError(dataset_code)
latest_release_code = find_latest_release_code(dataset_code_prefix, releases_json)
if latest_release_code is None:
raise NoDatasetReleaseError(dataset_code)
raise NoReleaseDefinedError(dataset_code)
return format_dataset_release(dataset_code_prefix, latest_release_code)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment