Changeset 229 for CCCC


Ignore:
Timestamp:
03/10/14 06:03:39 (6 years ago)
Author:
spascoe
Message:

Merge branch 'branch-sp'

File:
1 edited

Legend:

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

    r212 r229  
    475475    self.cc = checker(pcfg, c4i.project, ncReader,abortMessageCount=abortMessageCount) 
    476476    rec = recorder( c4i.project, c4i.recordFile, dummy=isDummy ) 
     477 
     478    # This list will record the drs dictionaries of all checked files for export to JSON 
     479    drs_list = [] 
     480 
    477481    if monitorFileHandles: 
    478482      self.monitor = utils.sysMonitor() 
     
    549553          if self.cc.errorCount == 0: 
    550554            rec.add( f, self.cc.drs ) 
     555            drs_list.append({'path': f, 'drs': self.cc.drs}) 
    551556          else: 
    552557            rec.addErr( f, 'ERRORS FOUND | errorCount = %s' % self.cc.errorCount ) 
     
    594599      rec.checktids() 
    595600    rec.dumpAll() 
     601 
     602    #!TODO: the recorder class could export JSON if it recorded the full drs dictionaries. 
     603    #       This lightweight solution re-uses the filename from the rec class and dumps 
     604    #       JSON in a separate function. 
     605    json_file = os.path.splitext(rec.file)[0] + '.json' 
     606    dump_drs_list(drs_list, json_file) 
     607 
    596608    if printInfo: 
    597609      print 'Error count %s' % ecount 
     
    601613 
    602614 
    603     
     615def dump_drs_list(drs_list, filename): 
     616    import json 
     617    fh = open(filename, 'w') 
     618    json.dump(drs_list, fh) 
     619    fh.close() 
    604620 
    605621 
Note: See TracChangeset for help on using the changeset viewer.