|
[Rivet-svn] r3944 - trunk/binblackhole at projects.hepforge.org blackhole at projects.hepforge.orgTue Oct 2 14:12:12 BST 2012
Author: dgrell Date: Tue Oct 2 14:12:12 2012 New Revision: 3944 Log: compare-histos now skips over broken AIDA files instead of hard stop Modified: trunk/bin/compare-histos Modified: trunk/bin/compare-histos ============================================================================== --- trunk/bin/compare-histos Sun Sep 30 22:19:20 2012 (r3943) +++ trunk/bin/compare-histos Tue Oct 2 14:12:12 2012 (r3944) @@ -59,19 +59,25 @@ logging.error(msg) raise Exception(msg) - +class AIDAreadException(Exception): pass + def getHistos(aidafile): '''Get a dictionary of histograms indexed by name.''' if not re.match(r'.*\.aida$', aidafile): logging.error("Error: input file '%s' is not an AIDA file" % aidafile) - sys.exit(2) + raise AIDAreadException aidafilepath = os.path.abspath(aidafile) if not os.access(aidafilepath, os.R_OK): logging.error("Error: cannot read from %s" % aidafile) - sys.exit(2) + raise AIDAreadException histos, titles, xlabels, ylabels = {}, {}, {}, {} - tree = ET.parse(aidafilepath) + try: + tree = ET.parse(aidafilepath) + except: + logging.error("Error: Cannot parse input file '%s' as AIDA file" % aidafile) + raise AIDAreadException + for dps in tree.findall("dataPointSet"): ## Get this histogram's path name dpsname = os.path.join(dps.get("path"), dps.get("name")) @@ -321,7 +327,10 @@ HISTOS[f] = {} LABELS[f] = {} for f in FILES+REFFILES: - histos, titles, xlabels, ylabels = getHistos(f) + try: + histos, titles, xlabels, ylabels = getHistos(f) + except AIDAreadException: + continue for n, h in histos.iteritems(): if h.isdata: l = "data"
More information about the Rivet-svn mailing list |