Changeset 143
- Timestamp:
- 01/04/14 10:21:59 (7 years ago)
- Location:
- CCCC/trunk
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
CCCC/trunk/amap2nco.py
r141 r143 104 104 import sys 105 105 if len(sys.argv) != 4: 106 print """USAGE: 107 python map2nco.py mappingsFile inputDirectoryBase outputDirectoryBase 106 if os.path.isfile( 'USAGE_amap2nco.txt' ): 107 for l in open( 'USAGE_amap2nco.txt').readlines(): 108 print string.strip(l) 109 else: 110 print """USAGE: 111 python amap2nco.py mappingsFile inputDirectoryBase outputDirectoryBase 108 112 mappingsFile: text file containing mapping information, generated by c4.py 109 113 inputDirectoryBase: initial part of the directory tree, to be replaced for corrected files 110 114 outputDirectoryBase: initial part of directory tree to be used for corrected files. 111 115 112 WARNING 113 Note that this feature will only correct errors where there is an unambiguous correct value 114 Users should check intermediary files to ensure that changes make sense 115 116 e.g. 117 ## run the checking program 118 python c4.py -p CORDEX -D /tmp/batch1 --ld batch1_logs 119 ## after checking, mv the amapDraft.txt file generated by c4.py 120 mv amapDraft.txt amap_batch1.txt 121 ## run the checking program in 'virtual substition' mode. If all errors are captured by the 122 ## substition list generated the code will indicate that there are no remaining errors. 123 python c4.py -p CORDEX -D /tmp/batch1 --ld batch1_logs --aMap amap_batch1.txt 124 125 ## the "amapDraft.txt" file contains a condensed view of substistution -- the 2nd run of c4.py 126 ## will create an extended list in "attributeMappingsLog.txt" 127 128 ## Generate a script to correct files 129 python map2nco.py attributeMappingsLog.txt /tmp/batch1 /tmp/batch1_corrected 130 ## 131 ## Run the script 132 bash ncoscript.sh 133 134 ## 135 ## check the modified files 136 python c4.py -p CORDEX -D /tmp/batch1_corrected --ld batch1_corrected_logs""" 116 See file USAGE_amap2nco.txt in code repository for more detail""" 137 117 138 118 else: -
CCCC/trunk/c4.py
r141 r143 133 133 self.da[m[1][0][1]][targ] = m[2][1] 134 134 self.atMapLog.write( '@ax:"%s","%s","%s","%s","%s"\n' % (self.fpath, m[1][0][1], targ, thisval, m[2][1]) ) 135 elif m[1][0][0] [0] != "@":135 elif m[1][0][0] == "@": 136 136 this = self.ga 137 137 apThis = True 138 for c in m[1]: 138 ## apply change where attribute absent only 139 for c in m[1][1:]: 139 140 if c[0] not in this.keys(): 140 apThis = False 141 elif c[1] != this[c[0]]: 141 if c[1] != '__absent__': 142 apThis = False 143 elif c[1] == '__absent__' or c[1] != this[c[0]]: 142 144 apThis = False 143 145 if m[2][0] != '': … … 148 150 if log != None: 149 151 log.info( 'Setting %s to %s' % (targ,m[2][1]) ) 150 print 'Setting %s:%s to %s' % (m[1][0][1],targ,m[2][1])152 ##print 'Setting %s to %s' % (targ,m[2][1]) 151 153 thisval = self.ga.get( targ, None ) 152 154 self.ga[targ] = m[2][1] -
CCCC/trunk/utils_c4.py
r141 r143 106 106 self.messageCount = 0 107 107 self.init() 108 if not hasattr( self.parent, 'amapListDraft' ): 109 self.parent.amapListDraft = [] 108 110 109 111 def isInt(self,x): … … 337 339 m.append(k) 338 340 339 gaerr = not self.test( len(m) == 0, 'Required global attributes missing: %s' % str(m) ) 341 if not self.test( len(m) == 0, 'Required global attributes missing: %s' % str(m) ): 342 gaerr = True 343 for k in m: 344 self.parent.amapListDraft.append( '#@;%s=%s|%s=%s' % (k,'__absent__',k,'<insert attribute value and uncomment>') ) 340 345 341 346 self.checkId = '002' … … 357 362 if not varAts[varName].has_key(k): 358 363 m.append(k) 359 vaerr = not self.test( len(m) == 0, 'Required variable attributes missing: %s' % str(m) ) 364 if not self.test( len(m) == 0, 'Required variable attributes missing: %s' % str(m) ): 365 vaerr = True 366 for k in m: 367 self.parent.amapListDraft.append( '#@var=%s;%s=%s|%s=%s' % (varName,k,'__absent__',k,'<insert attribute value and uncomment>') ) 368 print self.parent.amapListDraft[-1] 369 ##vaerr = not self.test( len(m) == 0, 'Required variable attributes missing: %s' % str(m) ) 360 370 361 371 ##if vaerr or gaerr: … … 417 427 raise 418 428 419 self.test( len(m) == 0, 'Global attributes do not match constraints: %s' % str(m) ) 429 if not self.test( len(m) == 0, 'Global attributes do not match constraints: %s' % str(m) ): 430 for t in m: 431 self.parent.amapListDraft.append( '#@;%s=%s|%s=%s' % (t[0],str(t[1]),t[0],'<insert attribute value and uncomment>' + str(t[2]) ) ) 420 432 421 433 self.checkId = '007'
Note: See TracChangeset
for help on using the changeset viewer.