TSVZ 3.27__tar.gz → 3.29__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: TSVZ
3
- Version: 3.27
3
+ Version: 3.29
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
File without changes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: TSVZ
3
- Version: 3.27
3
+ Version: 3.29
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
File without changes
File without changes
File without changes
@@ -22,10 +22,10 @@ if os.name == 'nt':
22
22
  elif os.name == 'posix':
23
23
  import fcntl
24
24
 
25
- version = '3.27'
25
+ version = '3.29'
26
26
  __version__ = version
27
27
  author = 'pan@zopyr.us'
28
- COMMIT_DATE = '2025-06-25'
28
+ COMMIT_DATE = '2025-08-11'
29
29
 
30
30
  DEFAULT_DELIMITER = '\t'
31
31
  DEFAULTS_INDICATOR_KEY = '#_defaults_#'
@@ -885,6 +885,29 @@ def scrubTabularFile(fileName,teeLogger = None,header = '',createIfNotExist = Fa
885
885
  appendLinesTabularFile(fileName,file,teeLogger = teeLogger,header = header,createIfNotExist = createIfNotExist,verifyHeader = verifyHeader,verbose = verbose,encoding = encoding,strict = strict,delimiter = delimiter)
886
886
  return file
887
887
 
888
+ def getListView(tsvzDic,header = [],delimiter = DEFAULT_DELIMITER):
889
+ if header:
890
+ if isinstance(header,str):
891
+ header = header.split(delimiter)
892
+ elif not isinstance(header,list):
893
+ try:
894
+ header = list(header)
895
+ except:
896
+ header = []
897
+ if not tsvzDic:
898
+ if not header:
899
+ return []
900
+ else:
901
+ return [header]
902
+ if not header:
903
+ return list(tsvzDic.values())
904
+ else:
905
+ values = list(tsvzDic.values())
906
+ if values[0] and values[0] == header:
907
+ return values
908
+ else:
909
+ return [header] + values
910
+
888
911
  # create a tsv class that functions like a ordered dictionary but will update the file when modified
889
912
  class TSVZed(OrderedDict):
890
913
  def __teePrintOrNot(self,message,level = 'info'):
@@ -1105,6 +1128,9 @@ class TSVZed(OrderedDict):
1105
1128
  self.__teePrintOrNot(f"Appending {emptyLine} to the appendQueue")
1106
1129
  self.appendQueue.append(emptyLine)
1107
1130
  return self
1131
+
1132
+ def getListView(self):
1133
+ return getListView(self,header=self.header,delimiter=self.delimiter)
1108
1134
 
1109
1135
  def clear(self):
1110
1136
  # clear the dictionary and update the file
@@ -1410,16 +1436,21 @@ memoryOnly:{self.memoryOnly}
1410
1436
  return self
1411
1437
 
1412
1438
  def stopAppendThread(self):
1413
- if self.shutdownEvent.is_set():
1414
- # if self.verbose:
1415
- # self.__teePrintOrNot(f"Append thread for {self._fileName} already stopped")
1416
- return
1417
- self.rewrite(force=self.rewrite_on_exit) # Ensure any final sync operations are performed
1418
- # self.appendEvent.set()
1419
- self.shutdownEvent.set() # Signal the append thread to shut down
1420
- self.appendThread.join() # Wait for the append thread to complete
1421
- if self.verbose:
1422
- self.__teePrintOrNot(f"Append thread for {self._fileName} stopped")
1439
+ try:
1440
+ if self.shutdownEvent.is_set():
1441
+ # if self.verbose:
1442
+ # self.__teePrintOrNot(f"Append thread for {self._fileName} already stopped")
1443
+ return
1444
+ self.rewrite(force=self.rewrite_on_exit) # Ensure any final sync operations are performed
1445
+ # self.appendEvent.set()
1446
+ self.shutdownEvent.set() # Signal the append thread to shut down
1447
+ self.appendThread.join() # Wait for the append thread to complete
1448
+ if self.verbose:
1449
+ self.__teePrintOrNot(f"Append thread for {self._fileName} stopped")
1450
+ except Exception as e:
1451
+ self.__teePrintOrNot(f"Failed to stop append thread for {self._fileName}: {e}",'error')
1452
+ import traceback
1453
+ self.__teePrintOrNot(traceback.format_exc(),'error')
1423
1454
 
1424
1455
  def get_file_obj(self,modes = 'ab'):
1425
1456
  self.writeLock.acquire()
@@ -1534,6 +1565,3 @@ def __main__():
1534
1565
  print("Invalid operation")
1535
1566
  if __name__ == '__main__':
1536
1567
  __main__()
1537
-
1538
-
1539
-
File without changes
File without changes