scripts: west_commands: patch: Support Python 3.10
The west patch command used hashlib.file_digest which was introduced in Python 3.11. Replace with a loop to support Python 3.10 (the current minimum). Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
This commit is contained in:
parent
a8d44c37c4
commit
c5d1e8e220
1 changed files with 5 additions and 1 deletions
|
@ -530,7 +530,11 @@ class Patch(WestCommand):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_file_sha256sum(filename: Path) -> str:
|
def get_file_sha256sum(filename: Path) -> str:
|
||||||
with open(filename, "rb") as fp:
|
with open(filename, "rb") as fp:
|
||||||
digest = hashlib.file_digest(fp, "sha256")
|
# NOTE: If python 3.11 is the minimum, the following can be replaced with:
|
||||||
|
# digest = hashlib.file_digest(fp, "sha256")
|
||||||
|
digest = hashlib.new("sha256")
|
||||||
|
while chunk := fp.read(2**10):
|
||||||
|
digest.update(chunk)
|
||||||
|
|
||||||
return digest.hexdigest()
|
return digest.hexdigest()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue