Changeset 199


Ignore:
Timestamp:
29/07/14 09:57:27 (6 years ago)
Author:
mjuckes
Message:

Meaningful error reporting for unparsable file names

Location:
CCCC/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • CCCC/trunk/ceda_cc/file_utils.py

    r180 r199  
    4646     self.atMapLog = attributeMappingsLog 
    4747     if self.atMapLog == None: 
    48        self.atMapLog = open( '/tmp/cccc_atMapLog.txt', 'a' ) 
     48       self.atMapLog = open( 'cccc_atMapLog.txt', 'a' ) 
    4949 
    5050  def close(self): 
  • CCCC/trunk/ceda_cc/utils_c4.py

    r193 r199  
    887887  def impt(self,flist): 
    888888    ee = {} 
     889    elist = [] 
    889890    for f in flist: 
    890891      fn = string.split(f, '/' )[-1] 
    891892      fnParts = string.split( fn[:-3], '_' ) 
    892       ##if self.cls == 'CORDEX': 
    893         ##isFixed = fnParts[7] == 'fx' 
    894         ##group = fnParts[7] 
    895       ##elif self.cls == 'SPECS': 
    896         ##isFixed = fnParts[1] == 'fx' 
    897         ##group = fnParts[1] 
    898  
    899       if self.pcfg.freqIndex != None: 
    900         freq = fnParts[self.pcfg.freqIndex] 
    901       else: 
    902         freq = None 
    903  
    904       isFixed = freq == 'fx' 
    905       group = fnParts[ self.pcfg.groupIndex ] 
    906  
    907       if isFixed: 
    908         trange = None 
    909       else: 
    910         trange = string.split( fnParts[-1], '-' ) 
    911       var = fnParts[0] 
    912       thisKey = string.join( fnParts[:-1], '.' ) 
    913       if group not in ee.keys(): 
    914         ee[group] = {} 
    915       if thisKey not in ee[group].keys(): 
    916         ee[group][thisKey] = [] 
    917       ee[group][thisKey].append( (f,fn,group,trange) ) 
     893       
     894      try: 
     895        if self.pcfg.freqIndex != None: 
     896          freq = fnParts[self.pcfg.freqIndex] 
     897        else: 
     898          freq = None 
     899 
     900        isFixed = freq == 'fx' 
     901        group = fnParts[ self.pcfg.groupIndex ] 
     902 
     903        if isFixed: 
     904          trange = None 
     905        else: 
     906          trange = string.split( fnParts[-1], '-' ) 
     907        var = fnParts[0] 
     908        thisKey = string.join( fnParts[:-1], '.' ) 
     909        if group not in ee.keys(): 
     910          ee[group] = {} 
     911        if thisKey not in ee[group].keys(): 
     912          ee[group][thisKey] = [] 
     913        ee[group][thisKey].append( (f,fn,group,trange) ) 
     914      except: 
     915        print 'Cannot parse file name: %s' % (f)  
     916        elist.append(f) 
     917## this ee entry is not used, except in bookkeeping check below.  
     918## parsing of file name is repeated later, and a error log entry is created at that stage -- this could be improved. 
     919## in order to improve, need to clarify flow of program: the list here is used to provide preliminary info before log files etc are set up. 
     920        group = '__error__' 
     921        thisKey = fn 
     922        if group not in ee.keys(): 
     923          ee[group] = {} 
     924        if thisKey not in ee[group].keys(): 
     925          ee[group][thisKey] = [] 
     926        ee[group][thisKey].append( (f,fn,group) ) 
    918927 
    919928    nn = len(flist) 
     
    924933 
    925934    assert nn==n2, 'some file lost!!!!!!' 
    926     self.info =  '%s files, %s frequencies' % (nn,len(ee.keys()) ) 
     935    if len(elist) == 0: 
     936      self.info =  '%s files, %s frequencies' % (nn,len(ee.keys()) ) 
     937    else: 
     938      self.info =  '%s files, %s frequencies, severe errors in file names: %s' % (nn,len(ee.keys()),len(elist) ) 
     939      for e in elist: 
     940        self.info += '\n%s' % e 
    927941    self.ee = ee 
    928942 
  • CCCC/trunk/setup.py

    r196 r199  
    1515 
    1616setup(name='ceda-cc', 
    17       version='1.1', 
     17      version='1.1.1', 
    1818      description="CEDA Conformance Checker", 
    1919      long_description=long_description, 
Note: See TracChangeset for help on using the changeset viewer.