wolph / python-progressbar

Progressbar 2 - A progress bar for Python 2 and Python 3 - "pip install progressbar2"
http://progressbar-2.readthedocs.org/en/latest/
BSD 3-Clause "New" or "Revised" License
859 stars 103 forks source link

Exposing isatty method in WrappingIO #254

Closed piotrbartman closed 3 years ago

piotrbartman commented 3 years ago

Description

If the use of click wrapping on stdout causes click to not recognize standard output as a terminal and all formatting (ANSI codes) is discarded.

Code

import click
import progressbar

progressbar.streams.wrap_stdout()
click.secho("text", fg="red")
# white text

It can be fixed by:

sys.stdout.isatty = progressbar.streams.original_stdout.isatty

I think it can be fixed by expose in WrappingIO class isatty method of target.

Versions

wolph commented 3 years ago

Thank you for the report and the suggested fix :)

It appears to be working great for me now so I've pushed a new release