TSVZ 3.14__py3-none-any.whl → 3.16__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
TSVZ.py CHANGED
@@ -22,7 +22,7 @@ if os.name == 'nt':
22
22
  elif os.name == 'posix':
23
23
  import fcntl
24
24
 
25
- version = '3.14'
25
+ version = '3.16'
26
26
  __version__ = version
27
27
  author = 'pan@zopyr.us'
28
28
 
@@ -56,8 +56,8 @@ def get_delimiter(delimiter,file_name = ''):
56
56
  DEFAULT_DELIMITER = rtn
57
57
  return rtn
58
58
 
59
- def pretty_format_table(data, delimiter = DEFAULT_DELIMITER):
60
- version = 1.0
59
+ def pretty_format_table(data, delimiter = DEFAULT_DELIMITER,header = None):
60
+ version = 1.1
61
61
  if not data:
62
62
  return ''
63
63
  if type(data) == str:
@@ -90,16 +90,34 @@ def pretty_format_table(data, delimiter = DEFAULT_DELIMITER):
90
90
  # Build the row format string
91
91
  row_format = ' | '.join('{{:<{}}}'.format(width) for width in col_widths)
92
92
  # Print the header
93
- header = data[0]
94
- outTable = []
95
- outTable.append(row_format.format(*header))
96
- outTable.append('-+-'.join('-' * width for width in col_widths))
97
- for row in data[1:]:
98
- # if the row is empty, print an divider
99
- if not any(row):
100
- outTable.append('-+-'.join('-' * width for width in col_widths))
101
- else:
102
- outTable.append(row_format.format(*row))
93
+ if not header:
94
+ header = data[0]
95
+ outTable = []
96
+ outTable.append(row_format.format(*header))
97
+ outTable.append('-+-'.join('-' * width for width in col_widths))
98
+ for row in data[1:]:
99
+ # if the row is empty, print an divider
100
+ if not any(row):
101
+ outTable.append('-+-'.join('-' * width for width in col_widths))
102
+ else:
103
+ outTable.append(row_format.format(*row))
104
+ else:
105
+ # pad / truncate header to appropriate length
106
+ if isinstance(header,str):
107
+ header = header.split(delimiter)
108
+ if len(header) < num_cols:
109
+ header += ['']*(num_cols-len(header))
110
+ elif len(header) > num_cols:
111
+ header = header[:num_cols]
112
+ outTable = []
113
+ outTable.append(row_format.format(*header))
114
+ outTable.append('-+-'.join('-' * width for width in col_widths))
115
+ for row in data:
116
+ # if the row is empty, print an divider
117
+ if not any(row):
118
+ outTable.append('-+-'.join('-' * width for width in col_widths))
119
+ else:
120
+ outTable.append(row_format.format(*row))
103
121
  return '\n'.join(outTable) + '\n'
104
122
 
105
123
  def format_bytes(size, use_1024_bytes=None, to_int=False, to_str=False,str_format='.2f'):
@@ -235,7 +253,10 @@ def __teePrintOrNot(message,level = 'info',teeLogger = None):
235
253
  """
236
254
  try:
237
255
  if teeLogger:
238
- teeLogger.teelog(message,level)
256
+ try:
257
+ teeLogger.teelog(message,level,callerStackDepth=3)
258
+ except:
259
+ teeLogger.teelog(message,level)
239
260
  else:
240
261
  print(message,flush=True)
241
262
  except Exception as e:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: TSVZ
3
- Version: 3.14
3
+ Version: 3.16
4
4
  Summary: An simple in memory wrapper around a TSV file to function as a database
5
5
  Home-page: https://github.com/yufei-pan/TSVZ
6
6
  Author: Yufei Pan
@@ -0,0 +1,6 @@
1
+ TSVZ.py,sha256=TpzTN4ExxJt2QO2IvOfGyMyo2f_2kzdk5jmel_aN53A,67863
2
+ tsvz-3.16.dist-info/METADATA,sha256=6yN2gCJs5LgREHWMC_Cj5pHtdmu_9R24L9xIm1g-eSQ,1826
3
+ tsvz-3.16.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
4
+ tsvz-3.16.dist-info/entry_points.txt,sha256=WeXidyV5yKCRLaVsnAY35xGa08QgytOfvr1CK9aescI,60
5
+ tsvz-3.16.dist-info/top_level.txt,sha256=OPx4LvOpaYykaos7oL_jGaObSWXxLzhHiWLuz-K147g,5
6
+ tsvz-3.16.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: setuptools (75.8.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,6 +0,0 @@
1
- TSVZ.py,sha256=Z2GXsKWfXFrjIHSg3gRldub4d6YvGt1fMTzuh-EZMjk,66968
2
- TSVZ-3.14.dist-info/METADATA,sha256=9L4OSMoMJKZrPr4MyPZn74S-1nHnf3LmSI_Kdd1u1ks,1826
3
- TSVZ-3.14.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
4
- TSVZ-3.14.dist-info/entry_points.txt,sha256=WeXidyV5yKCRLaVsnAY35xGa08QgytOfvr1CK9aescI,60
5
- TSVZ-3.14.dist-info/top_level.txt,sha256=OPx4LvOpaYykaos7oL_jGaObSWXxLzhHiWLuz-K147g,5
6
- TSVZ-3.14.dist-info/RECORD,,