1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2025-01-23 12:37:05 +00:00

Fixed SIM117 (multiple-with-statements): Use a single with statement with multiple contexts instead of nested with statements

This commit is contained in:
Teal Dulcet 2025-01-12 07:37:35 -08:00
parent bd0cb22467
commit 9896bfb765

View File

@ -72,9 +72,8 @@ def scan_files(collector):
if not os.path.exists(fn): if not os.path.exists(fn):
continue continue
if fn[-3:] == '.gz': if fn[-3:] == '.gz':
with tempfile.NamedTemporaryFile(delete=False) as tmp_file: with tempfile.NamedTemporaryFile(delete=False) as tmp_file, gzip.open(fn, 'rb') as f:
with gzip.open(fn, 'rb') as f: shutil.copyfileobj(f, tmp_file)
shutil.copyfileobj(f, tmp_file)
if VERBOSE: if VERBOSE:
print("Processing file", fn, "...") print("Processing file", fn, "...")