TSVZ 3.15__tar.gz → 3.17__tar.gz
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-3.15 → tsvz-3.17}/PKG-INFO +1 -1
- {tsvz-3.15 → tsvz-3.17}/TSVZ.egg-info/PKG-INFO +1 -1
- {tsvz-3.15 → tsvz-3.17}/TSVZ.py +34 -13
- {tsvz-3.15 → tsvz-3.17}/README.md +0 -0
- {tsvz-3.15 → tsvz-3.17}/TSVZ.egg-info/SOURCES.txt +0 -0
- {tsvz-3.15 → tsvz-3.17}/TSVZ.egg-info/dependency_links.txt +0 -0
- {tsvz-3.15 → tsvz-3.17}/TSVZ.egg-info/entry_points.txt +0 -0
- {tsvz-3.15 → tsvz-3.17}/TSVZ.egg-info/top_level.txt +0 -0
- {tsvz-3.15 → tsvz-3.17}/setup.cfg +0 -0
- {tsvz-3.15 → tsvz-3.17}/setup.py +0 -0
{tsvz-3.15 → tsvz-3.17}/PKG-INFO
RENAMED
{tsvz-3.15 → tsvz-3.17}/TSVZ.py
RENAMED
|
@@ -22,7 +22,7 @@ if os.name == 'nt':
|
|
|
22
22
|
elif os.name == 'posix':
|
|
23
23
|
import fcntl
|
|
24
24
|
|
|
25
|
-
version = '3.
|
|
25
|
+
version = '3.17'
|
|
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.
|
|
59
|
+
def pretty_format_table(data, delimiter = DEFAULT_DELIMITER,header = None):
|
|
60
|
+
version = 1.11
|
|
61
61
|
if not data:
|
|
62
62
|
return ''
|
|
63
63
|
if type(data) == str:
|
|
@@ -87,19 +87,40 @@ def pretty_format_table(data, delimiter = DEFAULT_DELIMITER):
|
|
|
87
87
|
#col_widths[c] = max(len(row[c]) for row in data)
|
|
88
88
|
# handle ansii escape sequences
|
|
89
89
|
col_widths[c] = max(len(re.sub(r'\x1b\[[0-?]*[ -/]*[@-~]','',row[c])) for row in data)
|
|
90
|
+
if header:
|
|
91
|
+
header_widths = [len(re.sub(r'\x1b\[[0-?]*[ -/]*[@-~]', '', col)) for col in header]
|
|
92
|
+
col_widths = [max(col_widths[i], header_widths[i]) for i in range(num_cols)]
|
|
90
93
|
# Build the row format string
|
|
91
94
|
row_format = ' | '.join('{{:<{}}}'.format(width) for width in col_widths)
|
|
92
95
|
# Print the header
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
96
|
+
if not header:
|
|
97
|
+
header = data[0]
|
|
98
|
+
outTable = []
|
|
99
|
+
outTable.append(row_format.format(*header))
|
|
100
|
+
outTable.append('-+-'.join('-' * width for width in col_widths))
|
|
101
|
+
for row in data[1:]:
|
|
102
|
+
# if the row is empty, print an divider
|
|
103
|
+
if not any(row):
|
|
104
|
+
outTable.append('-+-'.join('-' * width for width in col_widths))
|
|
105
|
+
else:
|
|
106
|
+
outTable.append(row_format.format(*row))
|
|
107
|
+
else:
|
|
108
|
+
# pad / truncate header to appropriate length
|
|
109
|
+
if isinstance(header,str):
|
|
110
|
+
header = header.split(delimiter)
|
|
111
|
+
if len(header) < num_cols:
|
|
112
|
+
header += ['']*(num_cols-len(header))
|
|
113
|
+
elif len(header) > num_cols:
|
|
114
|
+
header = header[:num_cols]
|
|
115
|
+
outTable = []
|
|
116
|
+
outTable.append(row_format.format(*header))
|
|
117
|
+
outTable.append('-+-'.join('-' * width for width in col_widths))
|
|
118
|
+
for row in data:
|
|
119
|
+
# if the row is empty, print an divider
|
|
120
|
+
if not any(row):
|
|
121
|
+
outTable.append('-+-'.join('-' * width for width in col_widths))
|
|
122
|
+
else:
|
|
123
|
+
outTable.append(row_format.format(*row))
|
|
103
124
|
return '\n'.join(outTable) + '\n'
|
|
104
125
|
|
|
105
126
|
def format_bytes(size, use_1024_bytes=None, to_int=False, to_str=False,str_format='.2f'):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tsvz-3.15 → tsvz-3.17}/setup.py
RENAMED
|
File without changes
|