Commit 69a284d 1 parent de1a27d commit 69a284d Copy full SHA for 69a284d
File tree 2 files changed +32
-3
lines changed
2 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -224,7 +224,7 @@ def same_file(result):
224
224
# cmip5.output1.ICHEC.EC-EARTH.historical
225
225
# .mon.atmos.Amon.r1i1p1.v20121115
226
226
variable = file .name .split ('_' )[0 ]
227
- if 'variable' in facets and facets ['variable' ] == variable :
227
+ if 'variable' not in facets or facets ['variable' ] == variable :
228
228
files .append (file )
229
229
else :
230
230
logger .debug (
@@ -279,8 +279,12 @@ def _get_facets(results):
279
279
facets = {
280
280
'project' : project ,
281
281
}
282
- for idx , key in enumerate (keys ):
283
- facets [key ] = values [idx ]
282
+ if len (keys ) == len (values ):
283
+ for idx , key in enumerate (keys ):
284
+ facets [key ] = values [idx ]
285
+ else :
286
+ logger .debug ("Wrong dataset_id_template_ %s for dataset %s" ,
287
+ template , dataset_id )
284
288
# The dataset_id does not contain the short_name for all projects,
285
289
# so get it from the filename if needed:
286
290
if 'short_name' not in facets :
Original file line number Diff line number Diff line change @@ -372,6 +372,31 @@ def test_select_by_time_nodate():
372
372
assert result == files
373
373
374
374
375
+ def test_invalid_dataset_id_template ():
376
+ dataset_id = (
377
+ 'obs4MIPs.IUP.XCH4_CRDP3.xch4.mon.v100' )
378
+ dataset_id_template = (
379
+ '%(project)s.%(institute)s.%(source_id)s.%(time_frequency)s'
380
+ )
381
+ filenames = ['xch4_ghgcci_l3_v100_200301_201412.nc' ]
382
+ results = [
383
+ FileResult (
384
+ json = {
385
+ 'title' : filename ,
386
+ 'dataset_id' : dataset_id + '|esgf.ceda.ac.uk' ,
387
+ 'dataset_id_template_' : [dataset_id_template ],
388
+ 'project' : ['obs4MIPs' ],
389
+ 'size' : 100 ,
390
+ 'source_id' : 'XCH4_CRDP3' ,
391
+ },
392
+ context = None ,
393
+ ) for filename in filenames
394
+ ]
395
+ file = ESGFFile (results )
396
+
397
+ assert file .name == filenames [0 ]
398
+
399
+
375
400
def test_search_unknown_project ():
376
401
project = 'Unknown'
377
402
msg = (f"Unable to download from ESGF, because project { project } is not on"
You can’t perform that action at this time.
0 commit comments