[docs]defsha1_checksum(uri:SimDBUrl)->str:"""Generate a SHA1 checksum from the given file. :param uri: the URI of the file to checksum :return: a string containing the hex representation of the computed SHA1 checksum """ifuri.scheme!="file":raiseValueError(f"invalid scheme for file checksum: {uri.scheme}")ifuri.pathisNone:raiseValueError("Path is not set")path=Path(uri.path)ifnotpath.exists():raiseValueError("File does not exist")ifnotpath.is_file():raiseValueError("File appears to be a directory")sha1=hashlib.sha1()withpath.open("rb")asfile:forchunkiniter(lambda:file.read(4096),b""):sha1.update(chunk)returnsha1.hexdigest()