@@ -225,7 +225,17 @@ def _network_js_close():
225
225
226
226
227
227
def is_http_uri (item ):
228
- return isinstance (item , six .string_types ) and (item .startswith ('http://' ) or item .startswith ('https://' ))
228
+ result = True
229
+ if not isinstance (item , six .string_types ):
230
+ result = False
231
+ else :
232
+ if not (item .startswith ('http://' ) or item .startswith ('https://' )):
233
+ result = False
234
+ if ',' in item :
235
+ result = False
236
+ if ' ' in item :
237
+ result = False
238
+ return result
229
239
230
240
231
241
class HttpCache (object ):
@@ -236,7 +246,7 @@ def __init__(self):
236
246
self .cache = {}
237
247
238
248
def is_http_uri (self , item ):
239
- return isinstance (item , six . string_types ) and ( item . startswith ( 'http://' ) or item . startswith ( 'https://' ) )
249
+ return is_http_uri (item )
240
250
241
251
def __getitem__ (self , item ):
242
252
@@ -527,6 +537,9 @@ def rdfnode(self, graph):
527
537
else :
528
538
rdfobj = self .unpack_rdfobject (obj , rdfpred )
529
539
if is_http_uri (rdfobj ):
540
+ # if rdfobj == 'http://www.ecmwf.int/research/EU_projects/ENSEMBLES/index.html, http://www.ecmwf.int/research/EU_projects/ENSEMBLES/experiments/index.html':
541
+ # import pdb; pdb.set_trace()
542
+
530
543
rdfobj = rdflib .URIRef (rdfobj )
531
544
else :
532
545
rdfobj = rdflib .Literal (rdfobj )
@@ -783,30 +796,31 @@ def load_netcdf(afilepath, baseuri=None, alias_dict=None, cache=None):
783
796
ig = terra .datetime .ISOGregorian ()
784
797
tog = terra .datetime .parse_datetime (origin ,
785
798
calendar = ig )
786
- dtype = '{}{}' .format (fhandle .variables [name ].dtype .kind ,
787
- fhandle .variables [name ].dtype .itemsize )
788
- fv = netCDF4 .default_fillvals .get (dtype )
789
- if fhandle .variables [name ][0 ] == fv :
790
- first = np .ma .MaskedArray (fhandle .variables [name ][0 ],
791
- mask = True )
792
- else :
793
- first = fhandle .variables [name ][0 ]
794
-
795
- edate_first = terra .datetime .EpochDateTimes (first ,
796
- quantity ,
797
- epoch = tog )
798
-
799
- sattrs ['bald__first_value' ] = str (edate_first )
800
- if len (fhandle .variables [name ]) > 1 :
799
+ if tog is not None :
800
+ dtype = '{}{}' .format (fhandle .variables [name ].dtype .kind ,
801
+ fhandle .variables [name ].dtype .itemsize )
802
+ fv = netCDF4 .default_fillvals .get (dtype )
801
803
if fhandle .variables [name ][0 ] == fv :
802
- last = np .ma .MaskedArray (fhandle .variables [name ][- 1 ],
803
- mask = True )
804
+ first = np .ma .MaskedArray (fhandle .variables [name ][0 ],
805
+ mask = True )
804
806
else :
805
- last = fhandle .variables [name ][- 1 ]
806
- edate_last = terra .datetime .EpochDateTimes (last ,
807
- quantity ,
808
- epoch = tog )
809
- sattrs ['bald__last_value' ] = str (edate_last )
807
+ first = fhandle .variables [name ][0 ]
808
+
809
+ edate_first = terra .datetime .EpochDateTimes (first ,
810
+ quantity ,
811
+ epoch = tog )
812
+
813
+ sattrs ['bald__first_value' ] = str (edate_first )
814
+ if len (fhandle .variables [name ]) > 1 :
815
+ if fhandle .variables [name ][0 ] == fv :
816
+ last = np .ma .MaskedArray (fhandle .variables [name ][- 1 ],
817
+ mask = True )
818
+ else :
819
+ last = fhandle .variables [name ][- 1 ]
820
+ edate_last = terra .datetime .EpochDateTimes (last ,
821
+ quantity ,
822
+ epoch = tog )
823
+ sattrs ['bald__last_value' ] = str (edate_last )
810
824
811
825
812
826
0 commit comments