Skip to content

Commit

Permalink
fix: handle mundi missing storageStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunato committed Jun 20, 2023
1 parent 2441b63 commit 1e26aaf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
42 changes: 23 additions & 19 deletions eodag/api/product/metadata_mapping.py
Expand Up @@ -675,7 +675,26 @@ def properties_from_xml(
path_or_text,
namespaces={k or empty_ns_prefix: v for k, v in root.nsmap.items()},
)
if len(extracted_value) == 1:
if len(extracted_value) <= 1:
if len(extracted_value) < 1:
# If there is no matched value (empty list), mark the metadata as not
# available
extracted_value = [NOT_AVAILABLE]
else:
# store element tag in used_xpaths
used_xpaths.append(
getattr(
root.xpath(
path_or_text.replace("/text()", ""),
namespaces={
k or empty_ns_prefix: v
for k, v in root.nsmap.items()
},
)[0],
"tag",
None,
)
)
if conversion_or_none is None:
properties[metadata] = extracted_value[0]
else:
Expand All @@ -695,22 +714,10 @@ def properties_from_xml(
"{%s%s%s}" % (metadata, SEP, conversion_or_none),
**{metadata: extracted_value[0]},
)
# store element tag in used_xpaths
used_xpaths.append(
getattr(
root.xpath(
path_or_text.replace("/text()", ""),
namespaces={
k or empty_ns_prefix: v for k, v in root.nsmap.items()
},
)[0],
"tag",
None,
)
)

# If there are multiple matches, consider the result as a list, doing a
# formatting if any
elif len(extracted_value) > 1:
else:
if conversion_or_none is None:
properties[metadata] = extracted_value
else:
Expand Down Expand Up @@ -743,10 +750,7 @@ def properties_from_xml(
)
for extracted_value_item in extracted_value
]
# If there is no matched value (empty list), mark the metadata as not
# available
else:
properties[metadata] = NOT_AVAILABLE

except XPathEvalError:
# Assume the mapping is to be passed as is, in which case we readily
# register it, or is a template, in which case we register it for later
Expand Down
2 changes: 1 addition & 1 deletion eodag/resources/providers.yml
Expand Up @@ -1355,7 +1355,7 @@
# is obtained from the provider or during the eodag download phase)
downloadLink: 'ns:link[@rel="enclosure"]/@href'
# storageStatus: must be one of ONLINE, STAGING, OFFLINE
storageStatus: 'DIAS:onlineStatus/text()'
storageStatus: '{DIAS:onlineStatus/text()#replace_str("Not Available","OFFLINE")}'
# order link formated for POST request usage
orderLink: 'https://apis.mundiwebservices.com/odrapi/0.1/request?{{"productId":"{id}","collectionId":"{platform}"}}'
searchLink: 'https://{platform}.browse.catalog.mundiwebservices.com/opensearch?uid={id}'
Expand Down

0 comments on commit 1e26aaf

Please sign in to comment.