Skip to content

Commit

Permalink
feat: added possibility to define license objects as list; updated cs…
Browse files Browse the repository at this point in the history
…d1 config file accordingly
  • Loading branch information
santilland committed Feb 23, 2024
1 parent 92516ed commit 701adbf
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 15 deletions.
6 changes: 4 additions & 2 deletions collections/CDS1_temperature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ DataSource:
Agency:
- European Commission
- ECMWF
License: proprietary |
([more information](https://cds.climate.copernicus.eu/api/v2/terms/static/licence-to-use-copernicus-products.pdf))
License:
- Url: https://cds.climate.copernicus.eu/api/v2/terms/static/licence-to-use-copernicus-products.pdf
Type: application/pdf
Title: Licence to Use Copernicus Products
Provider:
- Name: Copernicus Climate Change Service
Url: https://cds.climate.copernicus.eu/cdsapp#!/dataset/10.24381/cds.68d2bb30
Expand Down
50 changes: 37 additions & 13 deletions generators/generate_indicators.py
Original file line number Diff line number Diff line change
Expand Up @@ -1033,21 +1033,45 @@ def add_collection_information(config, collection, data):
# Add metadata information
# Check license identifier
if "License" in data:
license = lookup.by_id(data["License"])
if license is not None:
collection.license = license.id
if license.sources:
# add links to licenses
for source in license.sources:
collection.links.append(Link(
# Check if list was provided
if isinstance(data["License"], list):
if len(data["License"]) == 1:
collection.license = 'proprietary'
link = Link(
rel="license",
target=data["License"][0]["Url"],
media_type=data["License"][0]["Type"] if "Type" in data["License"][0] else "text/html",
)
if "Title" in data["License"][0]:
link.title = data["License"][0]["Title"]
collection.links.append(link)
elif len(data["License"]) > 1:
collection.license = 'various'
for l in data["License"]:
link = Link(
rel="license",
target=source,
media_type="text/html",
))
target=l["Url"],
media_type="text/html" if "Type" in l else l["Type"],
)
if "Title" in l:
link.title = l["Title"]
collection.links.append(link)
else:
# fallback to proprietary
print("WARNING: License could not be parsed, falling back to proprietary")
collection.license = "proprietary"
license = lookup.by_id(data["License"])
if license is not None:
collection.license = license.id
if license.sources:
# add links to licenses
for source in license.sources:
collection.links.append(Link(
rel="license",
target=source,
media_type="text/html",
))
else:
# fallback to proprietary
print("WARNING: License could not be parsed, falling back to proprietary")
collection.license = "proprietary"
else:
# print("WARNING: No license was provided, falling back to proprietary")
pass
Expand Down

0 comments on commit 701adbf

Please sign in to comment.