Skip to content

Commit

Permalink
Merge branch 'release/3.53.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
wolph committed Sep 9, 2020
2 parents 3715044 + 08bf420 commit f9aa7ed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion progressbar/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
long running operations.
'''.strip().split())
__email__ = 'wolph@wol.ph'
__version__ = '3.52.1'
__version__ = '3.53.0'
__license__ = 'BSD'
__copyright__ = 'Copyright 2015 Rick van Hattem (Wolph)'
__url__ = 'https://github.com/WoLpH/python-progressbar'
13 changes: 12 additions & 1 deletion progressbar/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import absolute_import
import distutils.util
import atexit
import io
import os
import re
Expand Down Expand Up @@ -193,12 +194,14 @@ def __init__(self, target, capturing=False, listeners=set()):
def write(self, value):
if self.capturing:
self.buffer.write(value)
if '\n' in value:
if '\n' in value: # pragma: no branch
self.needs_clear = True
for listener in self.listeners: # pragma: no branch
listener.update()
else:
self.target.write(value)
if '\n' in value:
self.flush_target()

def flush(self):
self.buffer.flush()
Expand All @@ -212,6 +215,13 @@ def _flush(self):
self.buffer.truncate(0)
self.needs_clear = False

# when explicitly flushing, always flush the target as well
self.flush_target()

def flush_target(self): # pragma: no cover
if not self.target.closed and getattr(self.target, 'flush'):
self.target.flush()


class StreamWrapper(object):
'''Wrap stdout and stderr globally'''
Expand Down Expand Up @@ -406,3 +416,4 @@ def __delattr__(self, name):

logger = logging.getLogger(__name__)
streams = StreamWrapper()
atexit.register(streams.flush)

0 comments on commit f9aa7ed

Please sign in to comment.