TSVZ 2.65__py3-none-any.whl → 2.67__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-2.65.dist-info → TSVZ-2.67.dist-info}/METADATA +1 -1
- TSVZ-2.67.dist-info/RECORD +7 -0
- TSVZ.py +24 -9
- TSVZ-2.65.dist-info/RECORD +0 -7
- {TSVZ-2.65.dist-info → TSVZ-2.67.dist-info}/LICENSE +0 -0
- {TSVZ-2.65.dist-info → TSVZ-2.67.dist-info}/WHEEL +0 -0
- {TSVZ-2.65.dist-info → TSVZ-2.67.dist-info}/entry_points.txt +0 -0
- {TSVZ-2.65.dist-info → TSVZ-2.67.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
TSVZ.py,sha256=uH4B8A5vLH3cfWlZ6cxK3jDDti4-QrcecAqWn0tCtSg,42942
|
|
2
|
+
TSVZ-2.67.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
3
|
+
TSVZ-2.67.dist-info/METADATA,sha256=KDidncBX1qN_Okaifsrp9W4kh1ofzEx6xXHtXQCQ_6U,1689
|
|
4
|
+
TSVZ-2.67.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
|
|
5
|
+
TSVZ-2.67.dist-info/entry_points.txt,sha256=WeXidyV5yKCRLaVsnAY35xGa08QgytOfvr1CK9aescI,60
|
|
6
|
+
TSVZ-2.67.dist-info/top_level.txt,sha256=OPx4LvOpaYykaos7oL_jGaObSWXxLzhHiWLuz-K147g,5
|
|
7
|
+
TSVZ-2.67.dist-info/RECORD,,
|
TSVZ.py
CHANGED
|
@@ -10,7 +10,7 @@ if os.name == 'nt':
|
|
|
10
10
|
elif os.name == 'posix':
|
|
11
11
|
import fcntl
|
|
12
12
|
|
|
13
|
-
version = '2.
|
|
13
|
+
version = '2.67'
|
|
14
14
|
author = 'pan@zopyr.us'
|
|
15
15
|
|
|
16
16
|
|
|
@@ -384,12 +384,22 @@ def clearTSV(fileName,teeLogger = None,header = '',verifyHeader = False,verbose
|
|
|
384
384
|
__teePrintOrNot(f"Cleared {fileName}",teeLogger=teeLogger)
|
|
385
385
|
|
|
386
386
|
def getFileUpdateTimeNs(fileName):
|
|
387
|
+
# return 0 if the file does not exist
|
|
388
|
+
if not os.path.isfile(fileName):
|
|
389
|
+
return 0
|
|
387
390
|
try:
|
|
388
391
|
return os.stat(fileName).st_mtime_ns
|
|
389
392
|
except:
|
|
390
393
|
__teePrintOrNot(f"Failed to get file update time for {fileName}",'error')
|
|
391
|
-
return
|
|
394
|
+
return get_time_ns()
|
|
392
395
|
|
|
396
|
+
def get_time_ns():
|
|
397
|
+
try:
|
|
398
|
+
return time.time_ns()
|
|
399
|
+
except:
|
|
400
|
+
# try to get the time in nanoseconds
|
|
401
|
+
return int(time.time()*1e9)
|
|
402
|
+
|
|
393
403
|
# create a tsv class that functions like a ordered dictionary but will update the file when modified
|
|
394
404
|
class TSVZed(OrderedDict):
|
|
395
405
|
def __teePrintOrNot(self,message,level = 'info'):
|
|
@@ -503,7 +513,7 @@ class TSVZed(OrderedDict):
|
|
|
503
513
|
if self.verbose:
|
|
504
514
|
self.__teePrintOrNot(f"Appending {key} to the appendQueue")
|
|
505
515
|
self.appendQueue.append('\t'.join(value))
|
|
506
|
-
self.lastUpdateTime =
|
|
516
|
+
self.lastUpdateTime = get_time_ns()
|
|
507
517
|
# if not self.appendThread.is_alive():
|
|
508
518
|
# self.commitAppendToFile()
|
|
509
519
|
# else:
|
|
@@ -521,7 +531,7 @@ class TSVZed(OrderedDict):
|
|
|
521
531
|
if self.memoryOnly:
|
|
522
532
|
return
|
|
523
533
|
self.__appendEmptyLine(key)
|
|
524
|
-
self.lastUpdateTime =
|
|
534
|
+
self.lastUpdateTime = get_time_ns()
|
|
525
535
|
|
|
526
536
|
def __appendEmptyLine(self,key):
|
|
527
537
|
self.dirty = True
|
|
@@ -614,7 +624,7 @@ memoryOnly:{self.memoryOnly}
|
|
|
614
624
|
key, value = super().popitem(last)
|
|
615
625
|
if not self.memoryOnly:
|
|
616
626
|
self.__appendEmptyLine(key)
|
|
617
|
-
self.lastUpdateTime =
|
|
627
|
+
self.lastUpdateTime = get_time_ns()
|
|
618
628
|
return key, value
|
|
619
629
|
|
|
620
630
|
__marker = object()
|
|
@@ -632,7 +642,7 @@ memoryOnly:{self.memoryOnly}
|
|
|
632
642
|
value = super().pop(key)
|
|
633
643
|
if not self.memoryOnly:
|
|
634
644
|
self.__appendEmptyLine(key)
|
|
635
|
-
self.lastUpdateTime =
|
|
645
|
+
self.lastUpdateTime = get_time_ns()
|
|
636
646
|
return value
|
|
637
647
|
|
|
638
648
|
def move_to_end(self, key, last=True):
|
|
@@ -647,7 +657,7 @@ memoryOnly:{self.memoryOnly}
|
|
|
647
657
|
self.__teePrintOrNot(f"rewrite_on_exit set to True")
|
|
648
658
|
if self.verbose:
|
|
649
659
|
self.__teePrintOrNot(f"Warning: Trying to move Key {key} moved to {'end' if last else 'beginning'} Need to resync for changes to apply to disk")
|
|
650
|
-
self.lastUpdateTime =
|
|
660
|
+
self.lastUpdateTime = get_time_ns()
|
|
651
661
|
return self
|
|
652
662
|
|
|
653
663
|
@classmethod
|
|
@@ -777,6 +787,8 @@ memoryOnly:{self.memoryOnly}
|
|
|
777
787
|
def checkExternalChanges(self):
|
|
778
788
|
if self.deSynced:
|
|
779
789
|
return self
|
|
790
|
+
if not self.monitor_external_changes:
|
|
791
|
+
return self
|
|
780
792
|
realExternalFileUpdateTime = getFileUpdateTimeNs(self._fileName)
|
|
781
793
|
if self.externalFileUpdateTime < realExternalFileUpdateTime:
|
|
782
794
|
self.deSynced = True
|
|
@@ -877,12 +889,15 @@ memoryOnly:{self.memoryOnly}
|
|
|
877
889
|
if self.verbose:
|
|
878
890
|
self.__teePrintOrNot(f"File {file.name} unlocked / released")
|
|
879
891
|
except Exception as e:
|
|
880
|
-
self.__teePrintOrNot(f"Failed to release file {file.name}: {e}",'error')
|
|
881
|
-
finally:
|
|
882
892
|
try:
|
|
883
893
|
self.writeLock.release() # Ensure the thread lock is always released
|
|
884
894
|
except Exception as e:
|
|
885
895
|
self.__teePrintOrNot(f"Failed to release writeLock for {file.name}: {e}",'error')
|
|
896
|
+
self.__teePrintOrNot(f"Failed to release file {file.name}: {e}",'error')
|
|
897
|
+
try:
|
|
898
|
+
self.writeLock.release() # Ensure the thread lock is always released
|
|
899
|
+
except Exception as e:
|
|
900
|
+
self.__teePrintOrNot(f"Failed to release writeLock for {file.name}: {e}",'error')
|
|
886
901
|
self.externalFileUpdateTime = getFileUpdateTimeNs(self._fileName)
|
|
887
902
|
|
|
888
903
|
|
TSVZ-2.65.dist-info/RECORD
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
TSVZ.py,sha256=tDsAV_zNosNEn5-FifNSgacdr9T-6zsQuZPZFkVakIc,42423
|
|
2
|
-
TSVZ-2.65.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
3
|
-
TSVZ-2.65.dist-info/METADATA,sha256=NxGY5k380-pEPwsTqQdUo3F52jiH8QexSbLcGN4Me94,1689
|
|
4
|
-
TSVZ-2.65.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
|
|
5
|
-
TSVZ-2.65.dist-info/entry_points.txt,sha256=WeXidyV5yKCRLaVsnAY35xGa08QgytOfvr1CK9aescI,60
|
|
6
|
-
TSVZ-2.65.dist-info/top_level.txt,sha256=OPx4LvOpaYykaos7oL_jGaObSWXxLzhHiWLuz-K147g,5
|
|
7
|
-
TSVZ-2.65.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|