From e4c8890d52e24dcedddcd5b2f81c597332c21dba Mon Sep 17 00:00:00 2001 From: "luz.paz" Date: Tue, 22 Oct 2019 16:39:38 -0400 Subject: [PATCH] Arch: Dice3DS/dom3ds.py LGTM fix Following recommendations from https://lgtm.com/rules/6770081/ --- src/Mod/Arch/Dice3DS/dom3ds.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/Mod/Arch/Dice3DS/dom3ds.py b/src/Mod/Arch/Dice3DS/dom3ds.py index e866be7aeb..3d688ce162 100644 --- a/src/Mod/Arch/Dice3DS/dom3ds.py +++ b/src/Mod/Arch/Dice3DS/dom3ds.py @@ -1786,11 +1786,8 @@ def read_3ds_file(filename,check_magic=True,tight=False,recover=True): """ - flo = open(filename,'rb') - try: + with open(filename,'rb') as flo: return read_3ds_mem(flo.read(),check_magic,tight,recover) - finally: - flo.close() def write_3ds_mem(dom,check_magic=True): @@ -1830,11 +1827,8 @@ def write_3ds_file(filename,dom,check_magic=True): if check_magic and dom.tag != 0x4D4D: raise File3dsFormatError("Not a 3D Studio file.") - flo = open(filename,'wb') - try: + with open(filename,'wb') as flo: flo.write(write_3ds_mem(dom,False)) - finally: - flo.close() def dump_3ds_chunk(chunk,flo,arraylines=10,indent=''): @@ -1907,5 +1901,3 @@ def remove_errant_chunks(chunk): setattr(chunk,attr,cl) for c in cl: remove_errant_chunks(c) - -