diff options
| author | Cody Logan <cody@lokken.dev> | 2023-11-07 12:39:32 -0800 |
|---|---|---|
| committer | Cody Logan <cody@lokken.dev> | 2023-11-07 12:39:32 -0800 |
| commit | 7099830a131b57f67be8e4d130df9dd995325609 (patch) | |
| tree | 31e9fbc6fd9ea812e1f66cfd2ee13ecce0306727 /src | |
| parent | 356a4c8bfbaeb9c5a720f57940098f0832ddb737 (diff) | |
| download | wikiget-7099830a131b57f67be8e4d130df9dd995325609.tar.gz wikiget-7099830a131b57f67be8e4d130df9dd995325609.zip | |
Use multiple context managers in a single with block
Diffstat (limited to 'src')
| -rw-r--r-- | src/wikiget/dl.py | 11 |
1 files changed, 5 insertions, 6 deletions
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: |
