CMS 3D CMS Logo

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