code: def compute_for_file(self, file, block_size=2**14):
          
          self.initialize_hashes()
          f = open(file, 'rb')
          while True:
              data = f.read(block_size)
              if not data:
                  break
              if (self.md5_calc is not None):
                  self.md5_calc.update(data)
              if (self.sha1_calc is not None):
                  self.sha1_calc.update(data)
              if (self.sha256_calc is not None):
                  self.sha256_calc.update(data)
          f.close()
docs: Compute hash digests for a file.
  
          Calculate the hashes based on one read through the file.
          Optional block_size parameter controls memory used to do
          calculations. This should be a multiple of 128 bytes.