[Rivet-svn] r2621 - in trunk: bin pyext

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Thu Jul 29 16:40:27 BST 2010


Author: fsiegert
Date: Thu Jul 29 16:40:26 2010
New Revision: 2621

Log:
compare-histos: While we are at changing its behaviour... allow for merging of multiple .plot files, such that the last one takes precedence. Allows to overwrite plot settings more selectively without having to modify the global .plot files or copying them completely.

Modified:
   trunk/bin/compare-histos
   trunk/pyext/lighthisto.py

Modified: trunk/bin/compare-histos
==============================================================================
--- trunk/bin/compare-histos	Wed Jul 28 20:18:33 2010	(r2620)
+++ trunk/bin/compare-histos	Thu Jul 29 16:40:26 2010	(r2621)
@@ -114,7 +114,7 @@
     parser.add_option("--refid", dest="REF_ID",
                       default="REF", help="ID of reference data set (file path for non-REF data)")
     parser.add_option("--plot-info-dir", dest="PLOTINFODIR", action="append",
-                      default=["./", rivet_data_dirs[0]], help="directory which may contain plot header information")
+                      default=[rivet_data_dirs[0], "./"], help="directory which may contain plot header information")
     parser.add_option("-q", "--quiet", help="Suppress normal messages", dest="LOGLEVEL",
                       action="store_const", default=logging.INFO, const=logging.WARNING)
     parser.add_option("-v", "--verbose", help="Add extra debug messages", dest="LOGLEVEL",

Modified: trunk/pyext/lighthisto.py
==============================================================================
--- trunk/pyext/lighthisto.py	Wed Jul 28 20:18:33 2010	(r2620)
+++ trunk/pyext/lighthisto.py	Thu Jul 29 16:40:26 2010	(r2621)
@@ -476,39 +476,35 @@
         if len(parts) != 3:
             raise ValueError("hpath has wrong number of parts (%i)" % (len(parts)))
         base = parts[1] + ".plot"
-        plotfile = None
+        ret = {'PLOT': {}, 'SPECIAL': None, 'HISTOGRAM': {}}
         for pidir in self.plotpaths:
             if os.access(os.path.join(pidir, base), os.R_OK):
                 plotfile = os.path.join(pidir, base)
-                break
-        if plotfile is None:
-            raise ValueError("No plot file %s found in plotpaths %s" % (base, self.plotpaths))
-        ret = {'PLOT': {}, 'SPECIAL': None, 'HISTOGRAM': {}}
-        startreading = False
-        f = open(plotfile)
-        for line in f:
-            m = self.pat_begin_block.match(line)
-            if m:
-                tag, pathpat = m.group(1,2)
-                if tag == section and pathpat == hpath:
-                    startreading=True
-                    if section in ['SPECIAL']:
-                        ret[section] = ''
-                    continue
-            if not startreading:
-                continue
-            if self.isEndMarker(line, section):
-                break
-            elif self.isComment(line):
-                continue
-            if section in ['PLOT', 'HISTOGRAM']:
-                vm = self.pat_property.match(line)
-                if vm:
-                    prop, value = vm.group(1,2)
-                    ret[section][prop] = value
-            elif section in ['SPECIAL']:
-                ret[section] += line
-        f.close()
+                startreading = False
+                f = open(plotfile)
+                for line in f:
+                    m = self.pat_begin_block.match(line)
+                    if m:
+                        tag, pathpat = m.group(1,2)
+                        if tag == section and pathpat == hpath:
+                            startreading=True
+                            if section in ['SPECIAL']:
+                                ret[section] = ''
+                            continue
+                    if not startreading:
+                        continue
+                    if self.isEndMarker(line, section):
+                        break
+                    elif self.isComment(line):
+                        continue
+                    if section in ['PLOT', 'HISTOGRAM']:
+                        vm = self.pat_property.match(line)
+                        if vm:
+                            prop, value = vm.group(1,2)
+                            ret[section][prop] = value
+                    elif section in ['SPECIAL']:
+                        ret[section] += line
+                f.close()
         return ret[section]
 
 


More information about the Rivet-svn mailing list