CMS 3D CMS Logo

TablePrint.py
Go to the documentation of this file.
1 from __future__ import print_function
2 from __future__ import absolute_import
3 import sys
4 from .colors import *
5 write = sys.stdout.write
6 
7 def PrettyPrintTable(Headers,Data,ColWidths,WarningCol=[],border='*'):
8  PrintHLine(ColWidths,border)
9  PrintLine(Headers,ColWidths,False,border)
10  PrintHLine(ColWidths,border)
11  if WarningCol==[]:
12  WarningCol=[False]*len(Data)
13  for [line,Warn] in zip(Data,WarningCol):
14  PrintLine(line,ColWidths,Warn,border)
15  PrintHLine(ColWidths,border)
16 
17 def PrintHLine(ColWidths,border):
19  for entry in ColWidths:
20  write(border)
21  for i in range(entry):
22  write(border)
23  write(border)
24  write('\n')
25 
26 def PrintLine(line,ColWidths,Warn,border):
27  assert Warn in [True,False]
28  try:
29  assert len(line)==len(ColWidths)
30  except:
31  print(line)
32  print(ColWidths)
33  raise
34  if Warn:
35  write(bcolors.FAIL)
36  for [width, entry] in zip(ColWidths,line):
37  write(border)
38  try:
39  entry = str(entry)
40  except:
41  print("\n\n\n Weird Data .. Bailing out\n\n")
42  sys.exit(0)
43  for i in range(width):
44  if i==0:
45  write(' ')
46  elif i<len(entry)+1:
47  write(entry[i-1])
48  else:
49  write(' ')
50  write(border)
51  write('\n')
52  write(bcolors.ENDC)
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def PrintLine(line, ColWidths, Warn, border)
Definition: TablePrint.py:26
def PrettyPrintTable(Headers, Data, ColWidths, WarningCol=[], border=' *')
Definition: TablePrint.py:7
#define str(s)
def PrintHLine(ColWidths, border)
Definition: TablePrint.py:17