From 8ad72ec59f37eb088375e5509644003c922245ca Mon Sep 17 00:00:00 2001 From: Alexander Walters Date: Mon, 17 Jul 2017 05:49:23 -0400 Subject: [PATCH] Update BookReporter.py (#782) replaces the lambda with a functools partial - slightly more performant, slightly less ugly --- src/tools/BookReporter.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tools/BookReporter.py b/src/tools/BookReporter.py index 68d6ca26e..4fb7388ac 100644 --- a/src/tools/BookReporter.py +++ b/src/tools/BookReporter.py @@ -11,6 +11,7 @@ import zipfile import shutil import json +import functools import Dictionary import CompareResults @@ -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() @@ -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) \ No newline at end of file + os.remove(tmpOutputFile)