Commit 2b780122 authored by abuddenberg's avatar abuddenberg
Browse files

start and end times are now parsed to ISO-8601 timestamps with incumbent...

start and end times are now parsed to ISO-8601 timestamps with incumbent exception handling and reporting
parent 6f5fd1ff
...@@ -4,6 +4,7 @@ import urllib ...@@ -4,6 +4,7 @@ import urllib
import requests import requests
import re import re
from os.path import join from os.path import join
from dateutil.parser import parse
from domain import Figure, Image, Dataset from domain import Figure, Image, Dataset
...@@ -55,10 +56,18 @@ class WebformClient: ...@@ -55,10 +56,18 @@ class WebformClient:
dataset = Dataset(dataset_json) dataset = Dataset(dataset_json)
#Commence the hacks #Commence the hacks
dataset.temporal_extent = ' -> '.join( try:
[dataset_json[field] for field in ['start_time', 'end_time'] dataset.temporal_extent = ' '.join(
if dataset_json[field] not in [None, '']] [parse(dataset_json[field]).isoformat() for field in ['start_time', 'end_time']]
) )
except TypeError, e:
print 'Problem with start/end time: ', fig_url, f.title, e
print dataset_json['start_time'], dataset_json['end_time']
dataset.temporal_extent = None
except ValueError, e:
print 'Problem with start/end time: ', fig_url, f.title, e
print dataset_json['start_time'], dataset_json['end_time']
dataset.temporal_extent = None
dataset.spatial_extent = ' '.join(['{k}: {v};'.format(k=key, v=dataset_json[key]) for key in dataset.spatial_extent = ' '.join(['{k}: {v};'.format(k=key, v=dataset_json[key]) for key in
['maximum_latitude', 'minimum_latitude', 'maximum_longitude', ['maximum_latitude', 'minimum_latitude', 'maximum_longitude',
......
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