MCPcopy
hub / github.com/ArchiveBox/ArchiveBox / bin_hash

Function bin_hash

archivebox/config.py:863–875  ·  view source on GitHub ↗
(binary: Optional[str])

Source from the content-addressed store, hash-verified

861 return shutil.which(str(Path(binary).expanduser())) or shutil.which(str(binary)) or binary
862
863def bin_hash(binary: Optional[str]) -> Optional[str]:
864 if binary is None:
865 return None
866 abs_path = bin_path(binary)
867 if abs_path is None or not Path(abs_path).exists():
868 return None
869
870 file_hash = md5()
871 with io.open(abs_path, mode='rb') as f:
872 for chunk in iter(lambda: f.read(io.DEFAULT_BUFFER_SIZE), b''):
873 file_hash.update(chunk)
874
875 return f'md5:{file_hash.hexdigest()}'
876
877def find_chrome_binary() -> Optional[str]:
878 """find any installed chrome binaries in the default locations"""

Callers 1

get_dependency_infoFunction · 0.85

Calls 1

bin_pathFunction · 0.85

Tested by

no test coverage detected