From 567e5f792dee1e777615e60144be4c201b5bc089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Sat, 24 Aug 2024 16:24:57 +0000 Subject: [PATCH] t.unregister: Open file with context handler (SIM115) --- temporal/t.unregister/t.unregister.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/temporal/t.unregister/t.unregister.py b/temporal/t.unregister/t.unregister.py index cacfe579a7b..a67ef91adb5 100755 --- a/temporal/t.unregister/t.unregister.py +++ b/temporal/t.unregister/t.unregister.py @@ -103,17 +103,16 @@ def main(): # Read the map list from file if file: - fd = open(file) - - line = True - while True: - line = fd.readline() - if not line: - break - - mapname = line.strip() - mapid = dummy.build_id(mapname, mapset) - maplist.append(mapid) + with open(file) as fd: + line = True + while True: + line = fd.readline() + if not line: + break + + mapname = line.strip() + mapid = dummy.build_id(mapname, mapset) + maplist.append(mapid) num_maps = len(maplist) update_dict = {}