ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
WebPage.htmlTable Class Reference
Collaboration diagram for WebPage.htmlTable:

Public Member Functions

def __init__ (self, tableAttr='', defaultCellAttr=[], useTableSorter=False, escapeText=False)
 
def __str__ (self)
 
def appendRow (self, cellData, rowAttr='')
 
def getHtml (self)
 

Public Attributes

 tableAttr
 
 defaultCellAttr
 
 useTableSorter
 
 escapeText
 
 rows
 

Detailed Description

Make a table. Table row data is accumulated internally in a list.
   The table can be made sortable (using jQuery's plugin Tablesorter)
   by setting useTableSorter to True. Special HTML characters in cell
   data are properly replaced (using escape from cgi) if escapeText
   is set True.

Definition at line 91 of file WebPage.py.

Constructor & Destructor Documentation

◆ __init__()

def WebPage.htmlTable.__init__ (   self,
  tableAttr = '',
  defaultCellAttr = [],
  useTableSorter = False,
  escapeText = False 
)

Definition at line 98 of file WebPage.py.

98  def __init__(self, tableAttr='', defaultCellAttr = [], useTableSorter=False, escapeText=False):
99  self.tableAttr = tableAttr
100  self.defaultCellAttr = defaultCellAttr
101  self.useTableSorter = useTableSorter
102  self.escapeText = escapeText
103  self.rows = [] # list of HTML strings with complete rows of the table
104 

Member Function Documentation

◆ __str__()

def WebPage.htmlTable.__str__ (   self)

Definition at line 105 of file WebPage.py.

105  def __str__(self):
106  return self.getHtml()
107 

◆ appendRow()

def WebPage.htmlTable.appendRow (   self,
  cellData,
  rowAttr = '' 
)
Append a row to the table. cellData is a list of the contents of
   the cells in the row. The data for each cell is either a string
   with the contents of the cell, or a tuple where the first element
   is the contents of the cell and the second element contains any
   HTML tags. Special HTML characters are properly replaced (using
   escape from cgi) if escapeText was set True when creating the
   table. If the table uses Tablesorter, <th> is used instead of
   <td> in the first row.

Definition at line 108 of file WebPage.py.

108  def appendRow(self, cellData, rowAttr=''):
109  """Append a row to the table. cellData is a list of the contents of
110  the cells in the row. The data for each cell is either a string
111  with the contents of the cell, or a tuple where the first element
112  is the contents of the cell and the second element contains any
113  HTML tags. Special HTML characters are properly replaced (using
114  escape from cgi) if escapeText was set True when creating the
115  table. If the table uses Tablesorter, <th> is used instead of
116  <td> in the first row."""
117  r = '<tr%s>\n' % sep(rowAttr)
118  if self.useTableSorter and len(self.rows)==0:
119  # First row using Tablesorter - must use <th> instead of <td>
120  cellFormat = '<th%s>%s</th>\n'
121  else:
122  cellFormat = '<td%s>%s</td>\n'
123  iCell = 0
124  for c in cellData:
125  cellAttr = self.defaultCellAttr[iCell] if iCell<len(self.defaultCellAttr) else ''
126  if isinstance(c,tuple):
127  r += cellFormat % (sep(c[1]),escape(str(c[0])) if self.escapeText else str(c[0]))
128  else:
129  r += cellFormat % (sep(cellAttr),escape(str(c)) if self.escapeText else str(c))
130  iCell += 1
131  r += '</tr>'
132  self.rows.append(r)
133 

◆ getHtml()

def WebPage.htmlTable.getHtml (   self)
Return the HTML code for the table.

Definition at line 134 of file WebPage.py.

134  def getHtml(self):
135  """Return the HTML code for the table."""
136  if len(self.rows)<1:
137  return ''
138  if self.useTableSorter:
139  if self.tableAttr:
140  h = '<table %s>\n' % self.tableAttr
141  else:
142  h = '<table class="tablesorter">\n'
143  h += '<thead>\n'
144  h += self.rows[0]
145  h += '\n</thead><tbody>\n'
146  h += '\n'.join(self.rows[1:])
147  h += '\n</tbody></table>\n'
148  else:
149  h = '<table%s>\n' % sep(self.tableAttr)
150  h += '\n'.join(self.rows)
151  h += '\n</table>\n'
152  return h
153 

Member Data Documentation

◆ defaultCellAttr

WebPage.htmlTable.defaultCellAttr

Definition at line 100 of file WebPage.py.

◆ escapeText

WebPage.htmlTable.escapeText

Definition at line 102 of file WebPage.py.

◆ rows

WebPage.htmlTable.rows

Definition at line 103 of file WebPage.py.

◆ tableAttr

WebPage.htmlTable.tableAttr

Definition at line 99 of file WebPage.py.

◆ useTableSorter

WebPage.htmlTable.useTableSorter

Definition at line 101 of file WebPage.py.


The documentation for this class was generated from the following file:
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
WebPage.sep
def sep(s)
Definition: WebPage.py:42
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
str
Definition: BTagTrackIpAccessor.cxx:11