CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
html.Page Class Reference
Inheritance diagram for html.Page:
html.TrackingIterPage

Public Member Functions

def __init__
 
def addPlotSet
 
def write
 

Private Member Functions

def _mapSectionName
 
def _orderSets
 

Private Attributes

 _content
 
 _plotSets
 

Detailed Description

Definition at line 112 of file html.py.

Constructor & Destructor Documentation

def html.Page.__init__ (   self,
  title,
  base,
  sampleName 
)

Definition at line 113 of file html.py.

114  def __init__(self, title, base, sampleName):
115  self._content = [
116  '<html>',
117  ' <head>',
118  ' <title>%s</title>' % title,
119  ]
120  if base is not None:
121  self._content.append(' <base href="%s"/>' % base)
122  self._content.extend([
123  ' </head>',
124  ' <body>',
125  ' '+sampleName,
126  ' <br/>',
127  ' <br/>',
128  ])
130  self._plotSets = {}
_content
Definition: html.py:114
_plotSets
Definition: html.py:129
def __init__
Definition: html.py:113

Member Function Documentation

def html.Page._mapSectionName (   self,
  section 
)
private

Definition at line 208 of file html.py.

Referenced by html.Page.write().

209  def _mapSectionName(self, section):
210  return _sectionNameMapOrder.get(section, section)
def _mapSectionName
Definition: html.py:208
def html.Page._orderSets (   self,
  keys 
)
private

Definition at line 211 of file html.py.

Referenced by html.Page.write().

212  def _orderSets(self, keys):
213  ret = []
214  for section in _sectionNameMapOrder.keys():
215  if section in keys:
216  ret.append(section)
217  keys.remove(section)
218  ret.extend(keys)
219  return ret
def _orderSets
Definition: html.py:211
def html.Page.addPlotSet (   self,
  section,
  plotSet 
)

Definition at line 131 of file html.py.

References html.Page._plotSets.

132  def addPlotSet(self, section, plotSet):
133  self._plotSets[section] = plotSet
def addPlotSet
Definition: html.py:131
_plotSets
Definition: html.py:129
def html.Page.write (   self,
  fileName 
)

Definition at line 134 of file html.py.

References html.Page._content, html.Page._mapSectionName(), html.Page._orderSets(), and html.Page._plotSets.

135  def write(self, fileName):
136  sections = self._orderSets(self._plotSets.keys())
137 
138  self._content.extend([
139  ' <table>'
140  ' <tr>',
141  ])
142 
143  fileTable = []
144  legends = []
145 
146  for isec, section in enumerate(sections):
147  leg = ""
148  if section in _sectionNameLegend:
149  legnum = len(legends)+1
150  leg = "<sup>%d</sup>" % legnum
151  leg2 = "<sup>%d</sup>" % legnum
152  legends.append("%s %s" % (leg2, _sectionNameLegend[section]))
153 
154  self._content.extend([
155  ' <td>%s%s</td>' % (self._mapSectionName(section), leg),
156  ])
157  files = [(os.path.basename(f), f) for f in self._plotSets[section]]
158  for row in fileTable:
159  found = False
160  for i, (bsf, f) in enumerate(files):
161  if bsf == row[0]:
162  row.append(f)
163  found = True
164  del files[i]
165  break
166  if not found:
167  row.append(None)
168  for bsf, f in files:
169  fileTable.append( [bsf] + [None]*isec + [f] )
170 
171  self._content.extend([
172  ' </tr>',
173  ])
174 
175  for row in fileTable:
176  self._content.append(' <tr>')
177  bs = row[0]
178  for elem in row[1:]:
179  if elem is not None:
180  self._content.append(' <td><a href="%s">%s</a></td>' % (elem, bs))
181  else:
182  self._content.append(' <td></td>')
183  self._content.append(' </tr>')
184 
185 
186  self._content.extend([
187  ' </table>',
188  ])
189  if len(legends) > 0:
190  self._content.extend([
191  ' <br/>'
192  ' Details:</br>',
193  ])
194  for leg in legends:
195  self._content.append(' %s<br/>' % leg)
196 
197  self._content.extend([
198  ' </body>',
199  '</html>',
200  ])
201 
202  #print "Writing HTML report page", fileName
203  f = open(fileName, "w")
204  for line in self._content:
205  f.write(line)
206  f.write("\n")
207  f.close()
_content
Definition: html.py:114
def _orderSets
Definition: html.py:211
_plotSets
Definition: html.py:129
def write
Definition: html.py:134
def _mapSectionName
Definition: html.py:208

Member Data Documentation

html.Page._content
private

Definition at line 114 of file html.py.

Referenced by html.Page.write().

html.Page._plotSets
private

Definition at line 129 of file html.py.

Referenced by html.Page.addPlotSet(), and html.Page.write().