Changeset 71
- Timestamp:
- 16/10/13 23:21:53 (7 years ago)
- Location:
- CCCC/branches/branch-as
- Files:
-
- 2 added
- 2 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
CCCC/branches/branch-as/c4.py
r68 r71 1 1 #!/usr/bin/env python 2 3 """ 4 c4.py 5 ===== 6 7 Command-line entry point for the CCCC quality checking tool. 8 9 This module contains as set of classes that manage the process and loggging. 10 11 The code depends on PCMDI's CDMS2 library (part of CDAT or CDAT-Lite). 12 13 """ 14 15 # Standard library imports 16 import os, string, time, sys 17 import logging 18 19 # Third-party imports 20 import cdms2 21 22 # Local imports 2 23 import utils_c4 as utils 3 24 import config_c4 as config 4 import os, string, time5 import logging6 25 7 26 reload( utils ) 8 import cdms29 27 10 28 vocabs = { 'variable':utils.mipVocab(), \ … … 22 40 #rcm_version_id = <RCMVersionID> 23 41 24 class dummy: 42 class Dummy(object): 43 "A simple container class." 25 44 pass 26 45 27 class recorder: 46 class Recorder(object): 47 "A class for recording the results of file checks." 28 48 29 49 def __init__(self,fileName,type='map'): … … 87 107 self.records[fn] = record 88 108 89 class checker: 109 class FileChecker(object): 110 "Class for checking data files." 111 90 112 def __init__(self): 91 self.info = dummy()113 self.info = Dummy() 92 114 self.calendar = 'None' 93 115 self.cfn = utils.checkFileName(parent=self.info) … … 159 181 self.errorCount = self.cfn.errorCount + self.cga.errorCount + self.cgd.errorCount + self.cgg.errorCount 160 182 161 class c4_init:183 class C4Init(object): 162 184 163 185 def __init__(self): … … 235 257 self.fHdlr.close() 236 258 237 cc = checker()259 cc = FileChecker() 238 260 239 261 cal = None 240 262 241 263 if __name__ == '__main__': 242 import sys 243 c4i = c4_init()244 rec = recorder( c4i.recordFile )264 265 c4i = C4Init() 266 rec = Recorder( c4i.recordFile ) 245 267 246 268 c4i.logger.info( 'Starting batch -- number of file: %s' % (len(c4i.flist)) ) … … 285 307 286 308 cc.info.log = c4i.logger 287 cbv.check( 309 cbv.check(recorder=rec, calendar=cc.calendar) 288 310 rec.dumpAll() 289 311 c4i.hdlr.close() -
CCCC/branches/branch-as/fcc_utils.py
r60 r71 5 5 ## 6 6 7 class mipTableScan:7 class MipTableScan(object): 8 8 9 9 def __init__(self, vats = ['standard_name','long_name','units','cell_methods'] ): … … 106 106 ## this class carries a logging method, and is used to carry information about datasets being parsed. 107 107 ## 108 class qcHandler: 108 class OLD_NOT_USED_qcHandler(object): 109 109 110 110 111 def __init__( self, qcc, log, baseDir, logPasses=True ): … … 179 180 self.msgk[key] += 1 180 181 181 class dirParser:182 class OLD_NOT_USED_dirParser: 182 183 183 184 def __init__(self, qcc, linksOnly=True): … … 353 354 handler.datasets[k][dsId].append( (dir,f, handler.nofail, ns) ) 354 355 355 class dataSetParser:356 class OLD_NOT_USED_dataSetParser: 356 357 357 358 def __init__(self,qcc, log, handler): … … 521 522 522 523 523 class dataset: 524 class Dataset(object): 525 "A container class for a dataset." 526 524 527 def __init__(self,name): 525 528 self.name = name 526 529 527 class qcConfigParse: 530 class OLD_NOT_USED_qcConfigParse(object): 531 "A class to parse configuration files for the QC process." 528 532 529 533 def __init__( self, file, log=None ): … … 560 564 elif l[0:6] == 'START ': 561 565 sname = string.strip( string.split(l)[1] ) 562 self._parse_l0_section = section_parser_l0( self, sname )566 self._parse_l0_section = SectionParserL0( self, sname ) 563 567 f = True 564 568 … … 573 577 for s in requiredSections: 574 578 assert s in self.sections.keys(), 'Required section %s not found in %s [parsing %s]' % (s, self.section.keys(),self.file) 575 self._parse_l1 = section_parser_l1( self )579 self._parse_l1 = SectionParserL1( self ) 576 580 self._parse_l1.parse( 'GENERAL' ) 577 581 self._parse_l1.parse( 'VOCABULARIES' ) … … 594 598 revsc = re.compile( 'validSectionCount,(.+)' ) 595 599 596 class section_parser_l1:600 class SectionParserL1(object): 597 601 598 602 def __init__(self,parent): … … 727 731 self.parent.vocab[id] = vlist[:] 728 732 if id == 'mipVarAtts': 729 self.mipsc = mipTableScan( vlist )733 self.mipsc = MipTableScan( vlist ) 730 734 731 735 def parse_filename(self): 732 736 sep = self.__get_match( refs, self.currentSection[1], 'File separator' ) 733 737 nn = map( int, string.split( self.__get_match( revsc, self.currentSection[2], 'File separator' ),',') ) 734 self.parent.fileNameSegments = fileNameSegments( self.parent, sep, nn )738 self.parent.fileNameSegments = FileNameSegments( self.parent, sep, nn ) 735 739 for l in self.currentSection[3:]: 736 740 self.parent.fileNameSegments.add(l) … … 864 868 self.datasetVersionMode.append( None ) 865 869 elif bits[0] == 'datasetId': 866 thisDs = dataset(bits[1])870 thisDs = Dataset(bits[1]) 867 871 thisDs.datasetIdMethod = bits[2] 868 872 if bits[2] == 'prints': … … 871 875 elif bits[2] == 'joinFileNameSegSlice': 872 876 thisSlice = slice( int(bits[4]), int(bits[5]) ) 873 thisDs.getDatasetId = dsid1( thisSlice, bits[3] ).get877 thisDs.getDatasetId = DSID1( thisSlice, bits[3] ).get 874 878 thisDs.datasetIdArg = 'fileNameBits' 875 879 elif bits[2] == 'cmip5': 876 880 thisSlice = slice( int(bits[4]), int(bits[5]) ) 877 thisDs.getDatasetId = cmip5_dsid( thisSlice, bits[3] ).get881 thisDs.getDatasetId = CMIP5DSID( thisSlice, bits[3] ).get 878 882 thisDs.datasetIdArg = 'filePathBits' 879 883 self.parent.datasets[bits[1]] = thisDs … … 907 911 self.parent.datasets[bb[k]].child = self.parent.datasets[bb[k+1]] 908 912 909 class dsid1:913 class DSID1(object): 910 914 911 915 def __init__(self,slice,sep): … … 916 920 return string.join( x[self.slice], self.sep ) 917 921 918 class cmip5_dsid:922 class CMIP5DSID(object): 919 923 920 924 def __init__(self,slice,sep): … … 926 930 927 931 928 class get_trange:932 class GetTRange(object): 929 933 930 934 def __init__(self,pat,kseg): … … 974 978 return self._get( l[self.kseg] ) 975 979 976 class fileNameSegments: 980 class FileNameSegments(object): 981 977 982 def __init__(self, parent, sep, nn ): 978 983 self.sep = sep … … 1001 1006 if bits[2] == 'TimeRange': 1002 1007 self.parent.hasTimeRange = True 1003 self.parent.timeRange = get_trange(regex,k)1008 self.parent.timeRange = GetTRange(regex,k) 1004 1009 1005 1010 def finish(self): … … 1244 1249 return ('VALUE',bits[1]) 1245 1250 1246 class section_parser_l0:1251 class SectionParserL0(object): 1247 1252 1248 1253 def __init__(self,parent,sectionName): -
CCCC/branches/branch-as/utils_c4.py
r69 r71 2 2 import string, re, os, sys 3 3 4 from fcc_utils import mipTableScan5 6 class reportSection:4 from fcc_utils import MipTableScan 5 6 class ReportSection: 7 7 8 8 def __init__(self,id,cls,parent=None, description=None): … … 20 20 def addSubSection( self, id, cls, description=None): 21 21 assert not self.closed, 'Attempt to add sub-section to closed report section' 22 self.subsections.append( reportSection(id, cls, parent=self, description=description ) )22 self.subsections.append( ReportSection(id, cls, parent=self, description=description ) ) 23 23 self.auditDone = False 24 24 return self.subsections[-1] … … 564 564 565 565 def __init__(self): 566 ms = mipTableScan()566 ms = MipTableScan() 567 567 dir = 'cordex_vocabs/mip/' 568 568 self.varInfo = {}
Note: See TracChangeset
for help on using the changeset viewer.