From 7099830a131b57f67be8e4d130df9dd995325609 Mon Sep 17 00:00:00 2001 From: Cody Logan Date: Tue, 7 Nov 2023 12:39:32 -0800 Subject: Use multiple context managers in a single with block --- src/wikiget/dl.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/wikiget') diff --git a/src/wikiget/dl.py b/src/wikiget/dl.py index 898e6ab..49b44ea 100644 --- a/src/wikiget/dl.py +++ b/src/wikiget/dl.py @@ -162,12 +162,11 @@ def download(f: File, args: Namespace) -> int: unit="B", unit_scale=True, unit_divisor=wikiget.CHUNKSIZE, - ) as progress_bar: - with fd: - res = site.connection.get(file_url, stream=True) - for chunk in res.iter_content(wikiget.CHUNKSIZE): - fd.write(chunk) - progress_bar.update(len(chunk)) + ) as progress_bar, fd: + res = site.connection.get(file_url, stream=True) + for chunk in res.iter_content(wikiget.CHUNKSIZE): + fd.write(chunk) + progress_bar.update(len(chunk)) # verify file integrity and log details try: -- cgit v1.2.3