Skip to content

Commit

Permalink
Update BookReporter.py (#782)
Browse files Browse the repository at this point in the history
replaces the lambda with a functools partial - slightly more performant, slightly less ugly
  • Loading branch information
tritium21 authored and tofi86 committed Jul 17, 2017
1 parent 68af5a9 commit 8ad72ec
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/tools/BookReporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import zipfile
import shutil
import json
import functools
import Dictionary
import CompareResults

Expand Down Expand Up @@ -93,7 +94,7 @@ def fileMD5(fileName):
md5 = hashlib.md5()
block_size = 128*md5.block_size
with open(fileName,'rb') as f:
for chunk in iter(lambda: f.read(block_size), b''):
for chunk in iter(functools.partial(f.read, block_size), b''):
md5.update(chunk)
return md5.hexdigest()

Expand Down Expand Up @@ -862,4 +863,4 @@ def compareMessages(newMessages, oldMessages):
#
elapsedTime = time.time() - startTime
if logging: logStats(statsLog, checkerVersion, targetDir, file, ePub, str(elapsedTime), str(checkTime), str(checkResults["publication"]["ePubVersion"]), str(oldPath), str(checkChanges), pubChanged, spineChanged, manifestChanged, str(messagesChanged), str(checkResults["checker"]["nFatal"]), str(checkResults["checker"]["nError"]), str(checkResults["publication"]["isScripted"]), str(checkResults["publication"]["hasFixedFormat"]))
os.remove(tmpOutputFile)
os.remove(tmpOutputFile)

0 comments on commit 8ad72ec

Please sign in to comment.