mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2025-01-24 12:47:05 +00:00
Fixed SIM115 (open-file-with-context-handler): Use a context manager for opening files
This commit is contained in:
parent
c59ff13c9f
commit
f13ae569d0
@ -72,9 +72,9 @@ 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':
|
||||||
tmp_file = tempfile.NamedTemporaryFile()
|
with tempfile.NamedTemporaryFile(delete=False) as tmp_file:
|
||||||
with 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, "...")
|
||||||
|
Loading…
Reference in New Issue
Block a user