diff cutils/treesum.py @ 381:ff4424a7a8cf

treesum: unit tests for generating and reading treesum files
author Franz Glasner <fzglas.hg@dom66.de>
date Sat, 17 May 2025 13:25:48 +0200
parents 6d7659a709f2
children dd0bc31064e4
line wrap: on
line diff
--- a/cutils/treesum.py	Mon May 12 15:33:16 2025 +0200
+++ b/cutils/treesum.py	Sat May 17 13:25:48 2025 +0200
@@ -2064,5 +2064,36 @@
         get_infos_from_digestfile([digest_file], self, True)
 
 
+class TreesumInfo(object):
+
+    def __init__(self):
+        self._algorithm = self._digest = self._size = None
+
+    def __call__(self, block_no, tag, generator, fsencoding, flags,
+                 fnmatch_filters, comments, errors,
+                 algorithm, digest, size):
+        self._algorithm = algorithm
+        self._digest = digest
+        self._size = size
+
+    @property
+    def algorithm(self):
+        return self._algorithm
+
+    @property
+    def digest(self):
+        return self._digest
+
+    @property
+    def size(self):
+        return self._size
+
+    @classmethod
+    def collect_last_from_file(cls, digest_file):
+        info = cls()
+        get_infos_from_digestfile([digest_file], info, True)
+        return info
+
+
 if __name__ == "__main__":
     sys.exit(main())