From 0cb90875bd5fe9493bb3022665228541ae35ccd0 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Thu, 28 Jan 2021 16:50:40 -0800 Subject: [PATCH] Use safeprint instead of always encoding to ascii. --- voussoirkit/spinal.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/voussoirkit/spinal.py b/voussoirkit/spinal.py index 908bbcc..ef1ebef 100644 --- a/voussoirkit/spinal.py +++ b/voussoirkit/spinal.py @@ -8,6 +8,7 @@ from voussoirkit import bytestring from voussoirkit import dotdict from voussoirkit import pathclass from voussoirkit import ratelimiter +from voussoirkit import safeprint from voussoirkit import sentinel from voussoirkit import winglob from voussoirkit import vlogging @@ -51,7 +52,6 @@ def callback_progress_v1(fpobj, written_bytes, total_bytes): Prints "filename written/total (percent%)" ''' - filename = fpobj.absolute_path.encode('ascii', 'replace').decode() if written_bytes >= total_bytes: ends = '\r\n' else: @@ -61,9 +61,8 @@ def callback_progress_v1(fpobj, written_bytes, total_bytes): written = '{:,}'.format(written_bytes) total = '{:,}'.format(total_bytes) written = written.rjust(len(total), ' ') - status = '{filename} {written}/{total} ({percent}%)\r' - status = status.format(filename=filename, written=written, total=total, percent=percent) - print(status, end=ends) + status = f'{fpobj.absolute_path} {written}/{total} ({percent}%)\r' + safeprint.safeprint(status, end=ends) sys.stdout.flush() def copy(source, file_args=None, file_kwargs=None, dir_args=None, dir_kwargs=None):