[Rivet-svn] r2961 - trunk/bin

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Tue Feb 22 23:47:35 GMT 2011


Author: buckley
Date: Tue Feb 22 23:47:34 2011
New Revision: 2961

Log:
Path-related script improvements

Modified:
   trunk/bin/aida2flat
   trunk/bin/compare-histos
   trunk/bin/rivet
   trunk/bin/rivet-mkhtml
   trunk/bin/rivet-rmgaps

Modified: trunk/bin/aida2flat
==============================================================================
--- trunk/bin/aida2flat	Tue Feb 22 23:46:46 2011	(r2960)
+++ trunk/bin/aida2flat	Tue Feb 22 23:47:34 2011	(r2961)
@@ -31,10 +31,14 @@
 
 if __name__ == "__main__":
 
-    ## TODO: replace with rivet.getAnalysisRefDirs()
-    rivet_data_dir = os.popen('rivet-config --datadir',"r").readline().strip()
-    if not rivet_data_dir:
-        rivet_data_dir = ""
+    ## Default plot file search paths
+    default_plotdirs = ["."]
+    try:
+        import rivet
+        default_plotdirs += rivet.getAnalysisPlotPaths()
+    except:
+        pass
+
 
     ## Parse command line options
     from optparse import OptionParser, OptionGroup
@@ -46,7 +50,7 @@
                       help="Provide output suitable for Gnuplot's 'plot \"foo.dat\" with xye'. Implies --split",
                       dest="GNUPLOT")
     parser.add_option("--plotinfodir", dest="PLOTINFODIR", action="append",
-                      default=["./", rivet_data_dir], help="directory which may contain plot header information")
+                      default=default_plotdirs, help="directory which may contain plot header information")
     parser.add_option("-S", "--smart-output", action="store_true", default=False,
                       help="Write to output files with names based on the corresponding input filename",
                       dest="SMARTOUTPUT")

Modified: trunk/bin/compare-histos
==============================================================================
--- trunk/bin/compare-histos	Tue Feb 22 23:46:46 2011	(r2960)
+++ trunk/bin/compare-histos	Tue Feb 22 23:47:34 2011	(r2961)
@@ -81,7 +81,9 @@
     from optparse import OptionParser, OptionGroup
     parser = OptionParser(usage=__doc__)
     parser.add_option("-R", "--rivet-refs", dest="RIVETREFS", action="store_true",
-                      default=False, help="try to use Rivet reference data files")
+                      default=True, help="use Rivet reference data files (default)")
+    parser.add_option("--no-rivet-refs", dest="RIVETREFS", action="store_false",
+                      default=True, help="don't use Rivet reference data files")
     parser.add_option("-o", "--outdir", dest="OUTDIR",
                       default=".", help="write data files into this directory")
     parser.add_option("--hier-out", action="store_true", dest="HIER_OUTPUT", default=False,

Modified: trunk/bin/rivet
==============================================================================
--- trunk/bin/rivet	Tue Feb 22 23:46:46 2011	(r2960)
+++ trunk/bin/rivet	Tue Feb 22 23:47:34 2011	(r2961)
@@ -60,7 +60,6 @@
 try:
     import rivet
     rivet.check_python_version()
-    #print rivet.getAnalysisLibPaths()
 except Exception, e:
     sys.stderr.write(PROGNAME + " requires the 'rivet' Python module\n")
     sys.stderr.write(str(e)+'\n')

Modified: trunk/bin/rivet-mkhtml
==============================================================================
--- trunk/bin/rivet-mkhtml	Tue Feb 22 23:46:46 2011	(r2960)
+++ trunk/bin/rivet-mkhtml	Tue Feb 22 23:47:34 2011	(r2961)
@@ -64,10 +64,6 @@
     sys.exit(1)
 
 
-## Get ref data search paths
-refpaths = rivet.getAnalysisRefPaths()
-
-
 ## Make output directory
 if os.path.exists(opts.OUTPUTDIR):
     import shutil
@@ -123,12 +119,10 @@
             if not matched:
                 continue
         analyses.add(analysis)
-        for refpath in refpaths:
-            if os.access(os.path.join(refpath, analysis+".aida"), os.R_OK):
-                reffile = "%s/%s.aida" % (refpath, analysis)
-                if not reffile in reffiles:
-                    reffiles.append(reffile)
-                    break
+        reffile = rivet.findAnalysisRefFile(analysis+".aida")
+        if reffile and reffile not in reffiles:
+            reffiles.append(reffile)
+            break
 
 
 ## Run compare-histos to get plain .dat files from .aida

Modified: trunk/bin/rivet-rmgaps
==============================================================================
--- trunk/bin/rivet-rmgaps	Tue Feb 22 23:46:46 2011	(r2960)
+++ trunk/bin/rivet-rmgaps	Tue Feb 22 23:47:34 2011	(r2961)
@@ -137,8 +137,10 @@
 import logging
 from optparse import OptionParser
 parser = OptionParser(usage=__doc__)
-parser.add_option("-R", "--rivet-refs", dest="USE_RIVETREFS", action="store_true", default=False,
-                  help="use the Rivet reference files by default")
+parser.add_option("-R", "--rivet-refs", dest="USE_RIVETREFS", action="store_true", default=True,
+                  help="use the Rivet reference data files for comparison")
+parser.add_option("--no-rivet-refs", dest="USE_RIVETREFS", action="store_true", default=True,
+                  help="don't use the Rivet reference data files for comparison")
 parser.add_option("-v", "--verbose", action="store_const", const=logging.DEBUG, dest="LOGLEVEL",
                   default=logging.INFO, help="print debug (very verbose) messages")
 parser.add_option("-q", "--quiet", action="store_const", const=logging.WARNING, dest="LOGLEVEL",
@@ -150,10 +152,9 @@
 
 
 if opts.USE_RIVETREFS:
-    REFDIRS = []
     try:
         import rivet
-        REFDIRS = rivet.getAnalysisRefPaths()
+        rivet.getAnalysisRefPaths()
     except:
         logging.error("Could not find the Rivet ref paths because the 'rivet' Python module could not be loaded")
         sys.exit(1)
@@ -205,11 +206,10 @@
         anas.add(ana)
     #print anas
     for a in anas:
-        for rd in REFDIRS:
-            rp = os.path.join(rd, a+".aida")
-            if os.access(rp, os.R_OK):
-                REFFILES.append(rp)
-                break
+        apath = rivet.findAnalysisRefFile(a+".aida")
+        if apath:
+            REFFILES.append(apath)
+            break
     #print REFFILES
 
 


More information about the Rivet-svn mailing list