[Rivet-svn] r3028 - in trunk: . bin

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Thu Mar 24 14:03:32 GMT 2011


Author: buckley
Date: Thu Mar 24 14:03:32 2011
New Revision: 3028

Log:
bin/aida2flat: Adding a -M option to *exclude* histograms whose paths match a regex. Writing a negative lookahead regex with positive matching was far too awkward!

Modified:
   trunk/ChangeLog
   trunk/bin/aida2flat

Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog	Mon Mar 21 19:38:15 2011	(r3027)
+++ trunk/ChangeLog	Thu Mar 24 14:03:32 2011	(r3028)
@@ -1,3 +1,9 @@
+2011-03-24  Andy Buckley  <andy at insectnation.org>
+
+	* bin/aida2flat: Adding a -M option to *exclude* histograms whose
+	paths match a regex. Writing a negative lookahead regex with
+	positive matching was far too awkward!
+
 2011-03-18  Leif Lönnblad  <Leif.Lonnblad at thep.lu.se>
 
 	* src/Core/AnalysisHandler.cc (AnalysisHandler::removeAnalysis):

Modified: trunk/bin/aida2flat
==============================================================================
--- trunk/bin/aida2flat	Mon Mar 21 19:38:15 2011	(r3027)
+++ trunk/bin/aida2flat	Thu Mar 24 14:03:32 2011	(r3028)
@@ -57,6 +57,9 @@
     parser.add_option("-m", "--match", action="append",
                       help="Only write out histograms whose $path/$name string matches these regexes",
                       dest="PATHPATTERNS")
+    parser.add_option("-M", "--unmatch", action="append",
+                      help="Exclude histograms whose $path/$name string matches these regexes",
+                      dest="PATHUNPATTERNS")
     verbgroup = OptionGroup(parser, "Verbosity control")
     verbgroup.add_option("-v", "--verbose", action="store_const", const=logging.DEBUG, dest="LOGLEVEL",
                          default=logging.INFO, help="print debug (very verbose) messages")
@@ -72,6 +75,8 @@
     ## Initialise steering variables which need a bit more care
     if opts.PATHPATTERNS is None:
         opts.PATHPATTERNS = []
+    if opts.PATHUNPATTERNS is None:
+        opts.PATHUNPATTERNS = []
     if opts.GNUPLOT:
         opts.SPLITOUTPUT = True
 
@@ -106,14 +111,22 @@
             sys.exit(1)
         histos = []
         for dps in tree.findall("dataPointSet"):
+
+            ## Pattern matching to include and/or exclude certain histo paths
             useThisDps = True
-            if len(opts.PATHPATTERNS) > 0:
+            dpspath = os.path.join(dps.get("path"), dps.get("name"))
+            if opts.PATHPATTERNS:
                 useThisDps = False
-                dpspath = os.path.join(dps.get("path"), dps.get("name"))
                 for regex in opts.PATHPATTERNS:
                     if re.compile(regex).search(dpspath):
                         useThisDps = True
                         break
+            if useThisDps and opts.PATHUNPATTERNS:
+                for regex in opts.PATHUNPATTERNS:
+                    if re.compile(regex).search(dpspath):
+                        useThisDps = False
+                        break
+
             if useThisDps:
                 hist = lighthisto.Histo.fromDPS(dps)
                 try:


More information about the Rivet-svn mailing list