Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
8bfabbe2
Commit
8bfabbe2
authored
Dec 29, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
python/build/verify: move code to feed_file()
parent
e334b16a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
8 deletions
+19
-8
verify.py
python/build/verify.py
+19
-8
No files found.
python/build/verify.py
View file @
8bfabbe2
import
hashlib
def
feed_file
(
h
,
f
):
"""Feed data read from an open file into the hashlib instance."""
while
True
:
data
=
f
.
read
(
65536
)
if
len
(
data
)
==
0
:
# end of file
break
h
.
update
(
data
)
def
feed_file_path
(
h
,
path
):
"""Feed data read from a file (to be opened by this function) into the hashlib instance."""
with
open
(
path
,
'rb'
)
as
f
:
feed_file
(
h
,
f
)
def
file_md5
(
path
):
"""Calculate the MD5 checksum of a file and return it in hexadecimal notation."""
with
open
(
path
,
'rb'
)
as
f
:
m
=
hashlib
.
md5
()
while
True
:
data
=
f
.
read
(
65536
)
if
len
(
data
)
==
0
:
# end of file
return
m
.
hexdigest
()
m
.
update
(
data
)
h
=
hashlib
.
md5
()
feed_file_path
(
h
,
path
)
return
h
.
hexdigest
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment