MCPcopy
hub / github.com/scrapy/scrapy / md5sum

Function md5sum

scrapy/utils/misc.py:138–160  ·  view source on GitHub ↗

Calculate the md5 checksum of a file-like object without reading its whole content in memory. >>> from io import BytesIO >>> md5sum(BytesIO(b'file content to hash')) '784406af91dd5a54fbb9c84c2236595a'

(file: IO[bytes])

Source from the content-addressed store, hash-verified

136
137
138def md5sum(file: IO[bytes]) -> str:
139 """Calculate the md5 checksum of a file-like object without reading its
140 whole content in memory.
141
142 >>> from io import BytesIO
143 >>> md5sum(BytesIO(b'file content to hash'))
144 '784406af91dd5a54fbb9c84c2236595a'
145 """
146 warnings.warn(
147 (
148 "The scrapy.utils.misc.md5sum function is deprecated and will be "
149 "removed in a future version of Scrapy."
150 ),
151 ScrapyDeprecationWarning,
152 stacklevel=2,
153 )
154 m = hashlib.md5() # noqa: S324
155 while True:
156 d = file.read(8096)
157 if not d:
158 break
159 m.update(d)
160 return m.hexdigest()
161
162
163def rel_has_nofollow(rel: str | None) -> bool:

Callers

nothing calls this directly

Calls 2

readMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected