[Rivet-svn] r4201 - in trunk: . doc pyext

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Wed Mar 6 17:37:44 GMT 2013


Author: buckley
Date: Wed Mar  6 17:37:44 2013
New Revision: 4201

Log:
Fixing doc build so that the reference histos and titles are ~correctly documented. We may want to truncate some of the lists!

Modified:
   trunk/ChangeLog
   trunk/doc/mk-analysis-latex
   trunk/pyext/lighthisto.py

Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog	Wed Mar  6 17:28:26 2013	(r4200)
+++ trunk/ChangeLog	Wed Mar  6 17:37:44 2013	(r4201)
@@ -1,3 +1,8 @@
+2013-03-06  Andy Buckley  <andy.buckley at cern.ch>
+
+	* Fixing doc build so that the reference histos and titles are
+	~correctly documented. We may want to truncate some of the lists!
+
 2013-03-06  Hendrik Hoeth <hendrik.hoeth at cern.ch>
 
 	* Added ATLAS_2012_I1125575 analysis

Modified: trunk/doc/mk-analysis-latex
==============================================================================
--- trunk/doc/mk-analysis-latex	Wed Mar  6 17:28:26 2013	(r4200)
+++ trunk/doc/mk-analysis-latex	Wed Mar  6 17:37:44 2013	(r4201)
@@ -182,20 +182,15 @@
         pp = lighthisto.PlotParser([os.path.join("..", "data", "plotinfo")])
         for hp in hpaths:
             attrs = pp.getHeaders(hp)
-            print "BAR", hp, attrs
             if attrs.has_key("Title"):
                 paths_titles[hp] = attrs["Title"]
-
-    print hpaths
-    print paths_titles
-
-    page = ""
     if paths_titles:
         page += "\n\\vspace{1em}\n\\noindent\n"
-        page += "\\textbf{Histograms:}\n \\penalty 100\n"
+        page += "\\textbf{Histograms (%d):}\n \\penalty 100\n" % len(paths_titles)
         page += "\\begin{itemize}\n"
         for hpath, htitle in sorted(paths_titles.iteritems()):
-            page += "  \\item %s (\\kbd{%s})\n" % (htitle, hpath.replace(r"_", r"\_"))
+            page += "  \\item %s ({\\smaller \\kbd{%s}})\n" % (htitle, hpath.replace(r"_", r"\_"))
+            # TODO: Truncate with a \dots after N ~ 50 or so?
         page += "\\end{itemize}\n"
     # except:
     #     pass

Modified: trunk/pyext/lighthisto.py
==============================================================================
--- trunk/pyext/lighthisto.py	Wed Mar  6 17:28:26 2013	(r4200)
+++ trunk/pyext/lighthisto.py	Wed Mar  6 17:37:44 2013	(r4201)
@@ -580,28 +580,17 @@
             If `plotpaths` is not specified and calling
             :command:`rivet-config` fails.
         """
-        if plotpaths is None:
-            plotpaths = []
-        self.plotpaths = plotpaths
-
         self.addfiles = addfiles
 
-        if len(self.plotpaths) == 0:
+        self.plotpaths = plotpaths
+        if not self.plotpaths:
             try:
                 import rivet
-                try:
-                    self.plotpaths = rivet.getAnalysisPlotPaths()
-                except AttributeError:
-                    self.plotpaths = rivet.getAnalysisRefPaths()
-                except AttributeError, e:
-                    sys.stderr.write("Failed to load Rivet analysis plot/reference paths: %s\n" % e)
-                    sys.stderr.write("Rivet version is too old.\n")
-                    raise ValueError("No plot paths given and rivet module is too old.")
-            except ImportError, e:
-                sys.stderr.write("Failed to import rivet module: %s\n" % e)
+                self.plotpaths = rivet.getAnalysisPlotPaths()
+            except e:
+                sys.stderr.write("Failed to load Rivet analysis plot paths: %s\n" % e)
                 raise ValueError("No plot paths given and the rivet module could not be loaded!")
 
-
     def getSection(self, section, hpath):
         """Get a section for a histogram from a .plot file.
 
@@ -610,7 +599,7 @@
         section : ('PLOT'|'SPECIAL'|'HISTOGRAM')
             The section that should be extracted.
         hpath : str
-            The histogram path, i.e. /AnaylsisID/HistogramID .
+            The histogram path, i.e. /AnalysisID/HistogramID .
 
         Todo
         ----
@@ -622,8 +611,11 @@
             raise ValueError("Can't parse section \'%s\'" %section)
 
         parts = hpath.split("/")
+        if parts[1] == "REF":
+            del parts[1]
+            hpath = "/".join(parts)
         if len(parts) != 3:
-            raise ValueError("hpath has wrong number of parts (%i)" % (len(parts)))
+            raise ValueError("hpath '%s' has wrong number of parts (%i) -- should be 3" % (hpath, len(parts)))
         base = parts[1] + ".plot"
         ret = {'PLOT': {}, 'SPECIAL': None, 'HISTOGRAM': {}}
         for pidir in self.plotpaths:
@@ -646,11 +638,12 @@
                     # pathpat could be a regex
                     if not self.pat_paths.has_key(pathpat):
                         self.pat_paths[pathpat] = re.compile(pathpat)
-                    if tag == section and self.pat_paths[pathpat].match(hpath):
-                        startreading = True
-                        if section in ['SPECIAL']:
-                            ret[section] = ''
-                        continue
+                    if tag == section:
+                        if self.pat_paths[pathpat].match(hpath):
+                            startreading = True
+                            if section in ['SPECIAL']:
+                                ret[section] = ''
+                            continue
                 if not startreading:
                     continue
                 if self.isEndMarker(line, section):


More information about the Rivet-svn mailing list