Hasher   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A digest() 0 13 4
1
#!/usr/bin/python
2
# -*- coding: UTF-8 -*-
3
import hashlib
4
5
6
class Hasher(object):
7
8
    blocksize = 512*8*128
9
10
    def digest(self, filename):
11
        """Determine the unique hash digest for a file.
12
13
        Note: takes 26s for a 14GB file.
14
15
        Args:
16
            filename (str): Path to the file for which a hash digest should be made.
17
        """
18
        hash = hashlib.md5()
19
        with open(filename, "rb") as f:
20
            for block in iter(lambda: f.read(self.blocksize), ""):
21
                hash.update(block)
22
        return hash.hexdigest()
23
24
25
26
27
28