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

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Tue Sep 29 13:02:11 BST 2009


Author: buckley
Date: Tue Sep 29 13:02:11 2009
New Revision: 1837

Log:
Optionally use cmd line args as case-insensitive regexes with the -l option

Modified:
   trunk/ChangeLog
   trunk/bin/rivet

Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog	Thu Sep 24 16:04:52 2009	(r1836)
+++ trunk/ChangeLog	Tue Sep 29 13:02:11 2009	(r1837)
@@ -1,6 +1,11 @@
+2009-09-29  Andy Buckley  <andy at insectnation.org>
+
+	* Adding optional use of args as regex match expressions with
+	-l/--list-analyses.
+
 2009-09-03  Andy Buckley  <andy.buckley at cern.ch>
 
-	* Passing GLS include path to compiler, since its absence was
+	* Passing GSL include path to compiler, since its absence was
 	breaking builds on systems with no GSL installation in a standard
 	location (such as SLC5, for some mysterious reason!)
 

Modified: trunk/bin/rivet
==============================================================================
--- trunk/bin/rivet	Thu Sep 24 16:04:52 2009	(r1836)
+++ trunk/bin/rivet	Tue Sep 29 13:02:11 2009	(r1837)
@@ -187,12 +187,26 @@
 ## List of analyses
 all_analyses = rivet.AnalysisLoader.analysisNames()
 if opts.LIST_ANALYSES:
+    ## Treat args as case-insensitive regexes if present
+    regexes = None
+    if args:
+        import re
+        regexes = [re.compile(arg, re.I) for arg in args]
     for aname in all_analyses:
-        msg = aname
-        if opts.LOGLEVEL == logging.DEBUG:
-            a = rivet.AnalysisLoader.getAnalysis(aname)
-            msg = "%-25s %s" % (aname, "  " + a.summary())
-        print msg
+        if not regexes:
+            toshow = True
+        else:
+            toshow = False
+            for regex in regexes:
+                if regex.search(aname):
+                    toshow = True
+                    break
+        if toshow:
+            msg = aname
+            if opts.LOGLEVEL == logging.DEBUG:
+                a = rivet.AnalysisLoader.getAnalysis(aname)
+                msg = "%-25s %s" % (aname, "  " + a.summary())
+            print msg
     sys.exit(0)
 
 
@@ -204,7 +218,7 @@
         if a_up in all_analyses and a_up not in toshow:
             toshow.append(a_up)
         else:
-            ## Treat as a regex
+            ## Treat as a case-insensitive regex
             import re
             regex = re.compile(a, re.I)
             for ana in all_analyses:


More information about the Rivet-svn mailing list