Commit bb2aff3f authored by Alessandro CERIONI's avatar Alessandro CERIONI
Browse files

Bugfix + fixes for the links related to the Sensor Observation Service.

parent b96ed37d
......@@ -10,11 +10,14 @@ def translate_content_type( content_type ):
# TODO: complete the following list!
types = ['pdf', 'html', 'zip', 'xml', 'javascript', 'json', 'csv']
for type in types:
if type in content_type:
return type.upper()
for the_type in types:
if the_type in content_type:
output = the_type.upper()
return content_type
output = content_type
return output
......@@ -27,7 +30,7 @@ def fix_links( links ):
# the 'description' attribute ends, sometimes, with (OGC:WMS), (OGC:WCS), ..., which is redundant and, in some case, erroneus.
if 'description' in link.keys():
fixed_links[k]['description'] = re.sub(r'\(OGC:WMS\)|\(OGC:WCS\)|\(OGC:WFS\)', '', link['description']).strip()
fixed_links[k]['description'] = re.sub(r'\(OGC:WMS\)|\(OGC:WCS\)|\(OGC:WFS\)|\(OGC:SOS\)', '', link['description']).strip()
# # FIX links pointing to external websites
# #logging.debug(link)
......@@ -36,8 +39,7 @@ def fix_links( links ):
# FIX links in which the declared protocol is as bizarre as "WWW:LINK-1.0-http--link"
# The KML protocol needs also to be fixed.
if 'protocol' in link.keys() and any( [x in link['protocol'] for x in ['WWW', 'kml'] ] ):
if 'protocol' in link.keys() and any( [x in link['protocol'] for x in ['WWW', 'kml', 'html'] ] ):
# let's try getting the information from the Web Server...
resp = requests.head( link['url'], allow_redirects=True )
......@@ -52,7 +54,7 @@ def fix_links( links ):
except Exception as e:
# ...otherwise, we make a guess on the basis of the information carried by the URL
known_formats = ['ecw', 'pdf', 'zip', 'kml', 'json', 'tif', 'tiff', 'csv']
known_formats = ['ecw', 'pdf', 'zip', 'kml', 'json', 'tif', 'tiff', 'csv', 'sos']
for known_format in known_formats:
if known_format in link['url'].lower():
......@@ -86,6 +88,13 @@ def fix_links( links ):
del fixed_links[k]
for k, link in enumerate(fixed_links):
if link['protocol'] == 'SOS':
if '?' in link['url']:
fixed_links[k]['url'] = link['url'].split('?')[:-1]
return fixed_links
......@@ -141,6 +150,22 @@ if __name__ == '__main__':
'description': "Licence ouverte",
'unknown': "1",
'protocol': "WWW-LINK"
'name': "Historique des disponibilités des stations Vélo'V(OGC:SOS)",
'description': "Historique des disponibilités des stations Vélo'V(OGC:SOS)",
'url': "",
'protocol': "WWW:LINK-1.0-http--link",
'content-type': "text/html",
'unknown': "1"
'name': "Démonstrateur WMS-Time",
'description': "Visualisation cartographique temporelle (WMS-T) de l'historique des disponibilités des stations Vélo'V",
'url': "",
'protocol': "text/html",
'content-type': "text/html",
'unknown': "1"
Supports Markdown
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