INNER CODE UNIT · Python
update_hash
terraform-aws-modules/terraform-aws-lambda · package.py:281
def update_hash(hash_obj, file_root, file_path=None):
"""
Update a hashlib object with the relative path and, if the given
file_path is not None, its content.
"""
if file_path is None:
hash_obj.update(file_root.encode())
return
relative_path = os.path.join(file_root, file_path)
hash_obj.update(relative_path.encode())
try:
with open(relative_path, "rb") as open_file:
while True:
data = open_file.read(1024 * 8)
if not data: