Switch from codecs.getreader to io.TextIOWrapper, refs #230

This commit is contained in:
Simon Willison 2021-02-14 10:33:26 -08:00
commit 1e9eb875a6
2 changed files with 4 additions and 4 deletions

View file

@ -105,9 +105,9 @@ class UpdateWrapper:
@contextlib.contextmanager
def file_progress(file, silent=False, **kwargs):
if silent or file.raw.fileno() == 0: # 0 = stdin
if silent or file.fileno() == 0: # 0 = stdin
yield file
else:
file_length = os.path.getsize(file.raw.name)
file_length = os.path.getsize(file.name)
with click.progressbar(length=file_length, **kwargs) as bar:
yield UpdateWrapper(file, bar.update)