TSVZ 3.17__py3-none-any.whl → 3.18__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 +15 -10
- {tsvz-3.17.dist-info → tsvz-3.18.dist-info}/METADATA +1 -1
- tsvz-3.18.dist-info/RECORD +6 -0
- tsvz-3.17.dist-info/RECORD +0 -6
- {tsvz-3.17.dist-info → tsvz-3.18.dist-info}/WHEEL +0 -0
- {tsvz-3.17.dist-info → tsvz-3.18.dist-info}/entry_points.txt +0 -0
- {tsvz-3.17.dist-info → tsvz-3.18.dist-info}/top_level.txt +0 -0
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.
|
|
25
|
+
version = '3.18'
|
|
26
26
|
__version__ = version
|
|
27
27
|
author = 'pan@zopyr.us'
|
|
28
28
|
|
|
@@ -60,7 +60,7 @@ def pretty_format_table(data, delimiter = DEFAULT_DELIMITER,header = None):
|
|
|
60
60
|
version = 1.11
|
|
61
61
|
if not data:
|
|
62
62
|
return ''
|
|
63
|
-
if
|
|
63
|
+
if isinstance(data, str):
|
|
64
64
|
data = data.strip('\n').split('\n')
|
|
65
65
|
data = [line.split(delimiter) for line in data]
|
|
66
66
|
elif isinstance(data, dict):
|
|
@@ -72,7 +72,7 @@ def pretty_format_table(data, delimiter = DEFAULT_DELIMITER,header = None):
|
|
|
72
72
|
else:
|
|
73
73
|
# it is a dict of lists
|
|
74
74
|
data = [[key] + list(value) for key, value in data.items()]
|
|
75
|
-
elif
|
|
75
|
+
elif not isinstance(data,list):
|
|
76
76
|
data = list(data)
|
|
77
77
|
# format the list into 2d list of list of strings
|
|
78
78
|
if isinstance(data[0], dict):
|
|
@@ -428,7 +428,7 @@ def _formatHeader(header,verbose = False,teeLogger = None,delimiter = DEFAULT_DE
|
|
|
428
428
|
Returns:
|
|
429
429
|
str: The formatted header string.
|
|
430
430
|
"""
|
|
431
|
-
if
|
|
431
|
+
if not isinstance(header,str):
|
|
432
432
|
try:
|
|
433
433
|
header = delimiter.join(header)
|
|
434
434
|
except:
|
|
@@ -647,17 +647,22 @@ def appendLinesTabularFile(fileName,linesToAppend,teeLogger = None,header = '',c
|
|
|
647
647
|
return
|
|
648
648
|
formatedLines = []
|
|
649
649
|
for line in linesToAppend:
|
|
650
|
-
if
|
|
650
|
+
if isinstance(linesToAppend,dict):
|
|
651
|
+
key = line
|
|
652
|
+
line = linesToAppend[key]
|
|
653
|
+
if isinstance(line,str):
|
|
651
654
|
line = line.split(delimiter)
|
|
652
|
-
|
|
655
|
+
elif line:
|
|
653
656
|
for i in range(len(line)):
|
|
654
|
-
if
|
|
657
|
+
if not isinstance(line[i],str):
|
|
655
658
|
try:
|
|
656
659
|
line[i] = str(line[i])
|
|
657
660
|
except Exception as e:
|
|
658
661
|
line[i] = str(e)
|
|
662
|
+
if isinstance(linesToAppend,dict):
|
|
663
|
+
if not line or line[0] != key:
|
|
664
|
+
line = [key]+line
|
|
659
665
|
formatedLines.append(line)
|
|
660
|
-
|
|
661
666
|
with open(fileName, mode ='r+b')as file:
|
|
662
667
|
correctColumnNum = max([len(line) for line in formatedLines])
|
|
663
668
|
if header.rstrip():
|
|
@@ -846,10 +851,10 @@ class TSVZed(OrderedDict):
|
|
|
846
851
|
if not key:
|
|
847
852
|
self.__teePrintOrNot('Key cannot be empty','error')
|
|
848
853
|
return
|
|
849
|
-
if
|
|
854
|
+
if isinstance(value,str):
|
|
850
855
|
value = value.split(self.delimiter)
|
|
851
856
|
# sanitize the value
|
|
852
|
-
value = [(str(segment).rstrip() if
|
|
857
|
+
value = [(str(segment).rstrip() if not isinstance(segment,str) else segment.rstrip()) if segment else '' for segment in value]
|
|
853
858
|
# escape the delimiter and newline characters
|
|
854
859
|
value = [segment.replace(self.delimiter,'<sep>').replace('\n','\\n') for segment in value]
|
|
855
860
|
# the first field in value should be the key
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
TSVZ.py,sha256=-1ciQsohzOZcZ8iYmlfw4JgFfUQBurV5104tpM26F9U,68319
|
|
2
|
+
tsvz-3.18.dist-info/METADATA,sha256=CGX-YrNOsZvau2hgduwOLbnXozNEqAEMP355LIli5sE,1826
|
|
3
|
+
tsvz-3.18.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
|
4
|
+
tsvz-3.18.dist-info/entry_points.txt,sha256=WeXidyV5yKCRLaVsnAY35xGa08QgytOfvr1CK9aescI,60
|
|
5
|
+
tsvz-3.18.dist-info/top_level.txt,sha256=OPx4LvOpaYykaos7oL_jGaObSWXxLzhHiWLuz-K147g,5
|
|
6
|
+
tsvz-3.18.dist-info/RECORD,,
|
tsvz-3.17.dist-info/RECORD
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
TSVZ.py,sha256=9ccdCwpUlduKSChPpZ1xaLpnVKSoBfkKHs2mtTm2PtI,68057
|
|
2
|
-
tsvz-3.17.dist-info/METADATA,sha256=4W_qIeWuVgvkQELUdgtAGEaycfFi-h-BCkv8eUwUvXs,1826
|
|
3
|
-
tsvz-3.17.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
|
4
|
-
tsvz-3.17.dist-info/entry_points.txt,sha256=WeXidyV5yKCRLaVsnAY35xGa08QgytOfvr1CK9aescI,60
|
|
5
|
-
tsvz-3.17.dist-info/top_level.txt,sha256=OPx4LvOpaYykaos7oL_jGaObSWXxLzhHiWLuz-K147g,5
|
|
6
|
-
tsvz-3.17.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|