leaf_focus/pdf/identify/component.py
def file_hash(self, path: Path):
        """Calculate the hash of a file."""

        if not path.exists():
            raise FileNotFoundError(f"Path does not exist '{path}'.")

        import hashlib

        sha256_hash = hashlib.sha256()
        with open(path, "rb") as f:
            # Read and update hash string value in blocks of 4K
            for byte_block in iter(lambda: f.read(4096), b""):
                sha256_hash.update(byte_block)
            return sha256_hash.hexdigest()
Calculate the hash of a file.
Calculate the hash of a file.
Calculate the hash of a file .
def file_hash(self, path: Path):
        if not path.exists():
            raise FileNotFoundError(f"Path does not exist '{path}'.")
        import hashlib
        sha256_hash = hashlib.sha256()
        with open(path, "rb") as f:
            for byte_block in iter(lambda: f.read(4096), b""):
                sha256_hash.update(byte_block)
            return sha256_hash.hexdigest()
def file_hash ( self , path : Path ) : if not path . exists ( ) : raise FileNotFoundError ( f"Path does not exist '{path}'." ) import hashlib sha256_hash = hashlib . sha256 ( ) with open ( path , "rb" ) as f : for byte_block in iter ( lambda : f . read ( 4096 ) , b"" ) : sha256_hash . update ( byte_block ) return sha256_hash . hexdigest ( )
Calculate the hash of a file.
Calculate the hash of a file .
"""Calculate the hash of a file.""" # Read and update hash string value in blocks of 4K
self
path
Path