MCPcopy Create free account
hub / github.com/koding/kite / sha1_file

Function sha1_file

kitectl/release.py:217–227  ·  view source on GitHub ↗

Calculate sha1 of path. Read file in chunks.

(path)

Source from the content-addressed store, hash-verified

215
216
217def sha1_file(path):
218 """Calculate sha1 of path. Read file in chunks."""
219 assert os.path.isfile(path)
220 chunk_size = 1024 * 1024 # 1M
221 sha1_checksum = hashlib.sha1()
222 with open(path, "rb") as f:
223 byte = f.read(chunk_size)
224 while byte:
225 sha1_checksum.update(byte)
226 byte = f.read(chunk_size)
227 return sha1_checksum.hexdigest()
228
229
230if __name__ == "__main__":

Callers 1

postbuild_osxFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected