resourceURI= getParam( 'resourceURI', 'http://autoplot.org/data/C1_CP_EDI_EGD__$Y$m$d_V03.cef', 'example file to load', [ 'data_$Y_$(m)_$(d;delta=7;phasestart=2019-05-05).qds', 'http://autoplot.org/data/C1_CP_EDI_EGD__$Y$m$d_V03.cef', 'C1_CP_EDI_EGD__$Y$m$d_$(enum,values=A|B).cef' ] ) timerange= getParam( 'timerange', '2005-02-12/2005-02-19', 'timerange to load' ) generate= getParam( 'generate', 'F', 'Generation doesn''t list remote folders', ['T','F'] ) if ( len(timerange.split(' '))==10 ): # make it easier to use Jon V.'s document "uri_template_test_cases.txt" trs= timerange.split(' ') timerange= '-'.join( trs[0:3] ) + 'T' + ':'.join( trs[3:5] ) + '/' + '-'.join( trs[5:8] ) + 'T' + ':'.join( trs[8:10] ) drtr= DatumRangeUtil.parseTimeRange(timerange) import time count=0 if ( False ): print params print '# resourceURI='+resourceURI print '# timerange='+timerange print '# generate='+generate print '' from java.lang import System t0= System.currentTimeMillis() if ( generate=='T' ): if ( resourceURI.find('$v')>-1 ): print 'Template cannot contain $v.' count=-1 else: tp= TimeParser.create(resourceURI) i1= resourceURI.find('$(enum') if ( i1>-1 ): ix= resourceURI.find('$(enum',i1+6) if (ix>-1 ): print 'Template can only contain one $(enum).' count=-1 else: fh= tp.getFieldHandlerByCode('enum') enums= fh.getValues() id= fh.getId() else: enums= [''] id= '' from java.util import Collections st= tp.format( drtr.min(), None, Collections.singletonMap( id, enums[0] ) ) dr= tp.parse( st,None ).getTimeRange() print( "

Generate Result

") print '

'+resourceURI+'

' print '

search limited to '+timerange+'

' print '' print '' while ( count<=10000 and dr.min().lt( drtr.max() ) ): for enum in enums: st= tp.format(dr.min(), dr.max(), Collections.singletonMap( id, enum ) ) print '' count= count+1 if ( count>10000 ): print '' break dr= dr.next() elif ( generate=='F' ): from org.das2.fsm import FileStorageModel from org.das2.util.filesystem import FileSystem i= FileStorageModel.splitIndex( resourceURI ) root= resourceURI[0:i] # the static part of the name template= resourceURI[i:] # the templated part of the name fs= FileSystem.create( root ) fsm= FileStorageModel.create( fs, template ) names= fsm.getNamesFor( DatumRangeUtil.parseTimeRange(timerange) ) print( "

Parse Result

") print '

'+resourceURI+'

' print '

search limited to '+timerange+'

' print '
Time RangeGenerated filename
'+ dr.toString() + ''+st + '
Search limited to 10000 results.
' print '' for n in names: print '' tr= fsm.getRangeFor( n ) try: v= fsm.getField('v',n) except: v= 'N/A' print '' count= count+1 print '' print '
FilenameTime RangeVersion
'+root + n + ''+tr.toString() + '' + v +'
' else: raise Exception('generate must be T or F') if ( count==0 ): print '(none found)' dt= System.currentTimeMillis() - t0 print '%d results calculated in %d milliseconds.\n' % ( count,dt ) print ''