summaryrefslogtreecommitdiff
path: root/dedup/hashing.py
diff options
context:
space:
mode:
Diffstat (limited to 'dedup/hashing.py')
-rw-r--r--dedup/hashing.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/dedup/hashing.py b/dedup/hashing.py
index 27f303c..9cebcbb 100644
--- a/dedup/hashing.py
+++ b/dedup/hashing.py
@@ -84,7 +84,7 @@ class HashBlacklistContent:
class DecompressedHash:
"""Apply a decompression function before the hash. This class provides the
hashlib interface (update, hexdigest, copy) excluding digest and name."""
- def __init__(self, decompressor, hashobj):
+ def __init__(self, decompressor, hashobj, name="unnamed"):
"""
@param decompressor: a decompression object like bz2.BZ2Decompressor or
lzma.LZMADecompressor. It has to provide methods decompress and
@@ -92,9 +92,11 @@ class DecompressedHash:
method.
@param hashobj: a hashlib-like obj providing methods update, hexdigest
and copy
+ @param name: initialized the name property
"""
self.decompressor = decompressor
self.hashobj = hashobj
+ self.name = name
def update(self, data):
self.hashobj.update(self.decompressor.decompress(data))
@@ -113,7 +115,8 @@ class DecompressedHash:
return tmphash.hexdigest()
def copy(self):
- return DecompressedHash(self.decompressor.copy(), self.hashobj.copy())
+ return DecompressedHash(self.decompressor.copy(), self.hashobj.copy(),
+ self.name)
class SuppressingHash:
"""A hash that silences exceptions from the update and hexdigest methods of