CMS 3D CMS Logo

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__ (self, title, sampleName)
 
def addPlotSet (self, section, plotSet)
 
def addTable (self, section, table)
 
def isEmpty (self)
 
def write (self, fileName)
 

Private Member Functions

def _appendColumnHeader (self, header)
 
def _appendLegend (self, section)
 
def _formatLegend (self)
 
def _formatPlotSets (self)
 
def _formatTables (self)
 
def _mapSectionName (self, section)
 
def _orderSets (self, keys)
 

Private Attributes

 _columnHeaders
 
 _columnHeadersIndex
 
 _content
 
 _legends
 
 _plotSets
 
 _sectionLegendIndex
 
 _tables
 

Detailed Description

Definition at line 350 of file html.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 351 of file html.py.

351  def __init__(self, title, sampleName):
352  self._content = [
353  '<html>',
354  ' <head>',
355  ' <title>%s</title>' % title,
356  ' </head>',
357  ' <body>',
358  ' '+sampleName,
359  ' <br/>',
360  ' <br/>',
361  ]
362 
363  self._plotSets = {}
364  self._tables = {}
365 

Member Function Documentation

◆ _appendColumnHeader()

def html.Page._appendColumnHeader (   self,
  header 
)
private

Definition at line 474 of file html.py.

474  def _appendColumnHeader(self, header):
475  leg = ""
476  if header in self._columnHeadersIndex:
477  leg = self._columnHeadersIndex[header]
478  else:
479  leg = str(chr(ord('A')+len(self._columnHeaders)))
480  self._columnHeaders.append("%s: %s" % (leg, header))
481  self._columnHeadersIndex[header] = leg
482  return leg
483 

References html.Table._columnHeaders, html.Page._columnHeaders, html.Page._columnHeadersIndex, mps_setup.append, and str.

Referenced by html.Page._formatTables().

◆ _appendLegend()

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

Definition at line 406 of file html.py.

406  def _appendLegend(self, section):
407  leg = ""
408  legends = _sectionNameLegend()
409  if section in legends:
410  if section in self._sectionLegendIndex:
411  leg = self._sectionLegendIndex[section]
412  else:
413  legnum = len(self._legends)+1
414  leg = "<sup>%d</sup>" % legnum
415  leg2 = "<sup>%d)</sup>" % legnum
416  self._legends.append("%s %s" % (leg2, legends[section]))
417  self._sectionLegendIndex[section] = leg
418  return leg
419 

References html.Page._legends, html.Page._sectionLegendIndex, html._sectionNameLegend(), and mps_setup.append.

Referenced by html.Page._formatPlotSets(), and html.Page._formatTables().

◆ _formatLegend()

def html.Page._formatLegend (   self)
private

Definition at line 538 of file html.py.

538  def _formatLegend(self):
539  if len(self._legends) > 0:
540  self._content.extend([
541  ' <br/>'
542  ' Details:</br>',
543  ])
544  for leg in self._legends:
545  self._content.append(' %s<br/>' % leg)
546 
547 

References html.Page._content, html.Page._legends, and mps_setup.append.

◆ _formatPlotSets()

def html.Page._formatPlotSets (   self)
private

Definition at line 420 of file html.py.

420  def _formatPlotSets(self):
421  self._content.extend([
422  ' <table>'
423  ' <tr>',
424  ])
425 
426  fileTable = []
427 
428  sections = self._orderSets(list(self._plotSets.keys()))
429  for isec, section in enumerate(sections):
430  leg = self._appendLegend(section)
431 
432  self._content.extend([
433  ' <td>%s%s</td>' % (self._mapSectionName(section), leg),
434  ])
435  files = [(os.path.basename(f), f) for f in self._plotSets[section]]
436  for row in fileTable:
437  found = False
438  for i, (bsf, f) in enumerate(files):
439  if bsf == row[0]:
440  row.append(f)
441  found = True
442  del files[i]
443  break
444  if not found:
445  row.append(None)
446  for bsf, f in files:
447  fileTable.append( [bsf] + [None]*isec + [f] )
448 
449  self._content.extend([
450  ' </tr>',
451  ])
452 
453  for row in fileTable:
454  self._content.append(' <tr>')
455  bs = row[0]
456  for elem in row[1:]:
457  if elem is not None:
458  self._content.append(' <td><a href="%s">%s</a></td>' % (elem, bs))
459  else:
460  self._content.append(' <td></td>')
461  self._content.append(' </tr>')
462 
463 
464  self._content.extend([
465  ' </table>',
466  ])
467 
468  if len(fileTable):
469  first_row = fileTable[0]
470  self._content.extend([
471  ' <a href="%s">Browse Folder</a>' % (first_row[1][0:first_row[1].rfind('/')])
472  ])
473 

References html.Page._appendLegend(), html.Page._content, html.Page._mapSectionName(), html.Page._orderSets(), html.Page._plotSets, mps_setup.append, and relativeConstraints.keys.

◆ _formatTables()

def html.Page._formatTables (   self)
private

Definition at line 484 of file html.py.

484  def _formatTables(self):
485  def _allNone(row):
486  for item in row:
487  if item is not None:
488  return False
489  return True
490 
491  sections = self._orderSets(list(self._tables.keys()))
492  for isec, section in enumerate(sections):
493  leg = self._appendLegend(section)
494 
495  table = self._tables[section]
496  self._content.extend([
497  ' <br/>',
498  ' %s%s' % (self._mapSectionName(section), leg),
499  ' <table border="1">'
500  ])
501 
502  # table is stored in column-row, need to transpose
503  data = table.tableAsRowColumn()
504 
505  self._content.extend([
506  ' <tr>'
507  ' <td></td>'
508  ])
509  heads = table.columnHeaders()
510  if max(map(lambda h: len(h), heads)) > 20:
511  heads = [self._appendColumnHeader(h) for h in heads]
512  for head in heads:
513  self._content.append(' <td>%s</td>' % head)
514  self._content.append(' </tr>')
515 
516  for irow, row in enumerate(data):
517  # Skip row if all values are non-existent
518  if _allNone(row):
519  continue
520 
521  self._content.extend([
522  ' <tr>'
523  ' <td>%s</td>' % table.rowHeaders()[irow]
524  ])
525  # align the number columns to right
526  for icol, item in enumerate(row):
527  formatted = str(item) if item is not None else ""
528  self._content.append(' <td align="right">%s</td>' % formatted)
529  self._content.append(' </tr>')
530 
531  self._content.append(' </table>')
532 
533  for shortenedColumnHeader in self._columnHeaders:
534  self._content.append(' %s<br/>' % shortenedColumnHeader)
535  self._columnHeaders = []
536  self._columnHeadersIndex = {}
537 

References html.Page._appendColumnHeader(), html.Page._appendLegend(), html.Table._columnHeaders, html.Page._columnHeaders, html.Page._columnHeadersIndex, html.Page._content, html.Page._mapSectionName(), html.Page._orderSets(), html.Page._tables, mps_setup.append, relativeConstraints.keys, genParticles_cff.map, SiStripPI.max, and str.

◆ _mapSectionName()

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

Reimplemented in html.TrackingIterPage.

Definition at line 548 of file html.py.

548  def _mapSectionName(self, section):
549  return _sectionNameMapOrder.get(section, section)
550 

Referenced by html.Page._formatPlotSets(), and html.Page._formatTables().

◆ _orderSets()

def html.Page._orderSets (   self,
  keys 
)
private

Reimplemented in html.TrackingIterPage.

Definition at line 551 of file html.py.

551  def _orderSets(self, keys):
552  keys_sorted = sorted(keys)
553  ret = []
554  for section in _sectionNameMapOrder.keys():
555  if section in keys_sorted:
556  ret.append(section)
557  keys_sorted.remove(section)
558  ret.extend(keys_sorted)
559  return ret
560 

Referenced by html.Page._formatPlotSets(), and html.Page._formatTables().

◆ addPlotSet()

def html.Page.addPlotSet (   self,
  section,
  plotSet 
)

Definition at line 366 of file html.py.

366  def addPlotSet(self, section, plotSet):
367  if section in self._plotSets:
368  self._plotSets[section].extend(plotSet)
369  else:
370  self._plotSets[section] = plotSet
371 

References html.Page._plotSets.

◆ addTable()

def html.Page.addTable (   self,
  section,
  table 
)

Definition at line 372 of file html.py.

372  def addTable(self, section, table):
373  self._tables[section] = table
374 

References html.Page._tables.

◆ isEmpty()

def html.Page.isEmpty (   self)

Definition at line 375 of file html.py.

375  def isEmpty(self):
376  for plotSet in self._plotSets.values():
377  if len(plotSet) > 0:
378  return False
379 
380  if len(self._tables) > 0:
381  return False
382 
383  return True
384 

References html.Page._plotSets, html.Page._tables, and contentValuesCheck.values.

Referenced by plotting.Plot.clone().

◆ write()

def html.Page.write (   self,
  fileName 
)

Definition at line 385 of file html.py.

385  def write(self, fileName):
386  self._legends = []
387  self._sectionLegendIndex = {}
388  self._columnHeaders = []
389  self._columnHeadersIndex = {}
390  self._formatPlotSets()
391  self._formatTables()
392  self._formatLegend()
393 
394  self._content.extend([
395  ' </body>',
396  '</html>',
397  ])
398 
399  #print "Writing HTML report page", fileName
400  f = open(fileName, "w")
401  for line in self._content:
402  f.write(line)
403  f.write("\n")
404  f.close()
405 

Member Data Documentation

◆ _columnHeaders

html.Page._columnHeaders
private

Definition at line 388 of file html.py.

Referenced by html.Page._appendColumnHeader(), and html.Page._formatTables().

◆ _columnHeadersIndex

html.Page._columnHeadersIndex
private

Definition at line 389 of file html.py.

Referenced by html.Page._appendColumnHeader(), and html.Page._formatTables().

◆ _content

html.Page._content
private

◆ _legends

html.Page._legends
private

Definition at line 386 of file html.py.

Referenced by html.Page._appendLegend(), and html.Page._formatLegend().

◆ _plotSets

html.Page._plotSets
private

Definition at line 363 of file html.py.

Referenced by html.Page._formatPlotSets(), html.Page.addPlotSet(), and html.Page.isEmpty().

◆ _sectionLegendIndex

html.Page._sectionLegendIndex
private

Definition at line 387 of file html.py.

Referenced by html.Page._appendLegend().

◆ _tables

html.Page._tables
private

Definition at line 364 of file html.py.

Referenced by html.Page._formatTables(), html.Page.addTable(), and html.Page.isEmpty().

html._sectionNameLegend
def _sectionNameLegend()
Definition: html.py:261
relativeConstraints.keys
keys
Definition: relativeConstraints.py:89
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
str
#define str(s)
Definition: TestProcessor.cc:53
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
mps_setup.append
append
Definition: mps_setup.py:85
writeEcalDQMStatus.write
write
Definition: writeEcalDQMStatus.py:48
genParticles_cff.map
map
Definition: genParticles_cff.py:11