From 24da92d39ef4b648317b7fc9a091209aa865dc22 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Fri, 17 May 2019 14:56:33 -0700 Subject: [PATCH] Fix extra blank lines in output messages in Python 3.6 --- src/ocrmypdf/__main__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ocrmypdf/__main__.py b/src/ocrmypdf/__main__.py index e48283c2..eaf894ef 100755 --- a/src/ocrmypdf/__main__.py +++ b/src/ocrmypdf/__main__.py @@ -471,10 +471,15 @@ class TqdmConsole: def __init__(self, file): self.file = file + self.py36 = sys.version_info >= (3, 6) def write(self, msg): # When no progress bar is active, tqdm.write() routes to print() - tqdm.write(msg.rstrip(), file=self.file) + if self.py36: + if msg.strip() != '': + tqdm.write(msg.rstrip(), end='\n', file=self.file) + else: + tqdm.write(msg.rstrip(), end='\n', file=self.file) def flush(self): if hasattr(self.file, "flush"):