From 29634278eb84fcdd1b29b85ed2ce8c5250e4a183 Mon Sep 17 00:00:00 2001 From: Dirk Mallunat Date: Tue, 5 Jul 2016 00:09:20 +0200 Subject: Close config file Signed-off-by: Florian Pritz --- fb.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fb.py b/fb.py index 1557ed9..4e46c1f 100755 --- a/fb.py +++ b/fb.py @@ -385,10 +385,11 @@ class ConfigParser: if ignoreMissing: return - for line in fh.readlines(): - matches = re.match('^(?P[^=]+)=(?P"?)(?P.+)(?P=quotechar)$', line) - if matches != None: - self.config[matches.group('key')] = matches.group('value') + with fh: + for line in fh: + matches = re.match('^(?P[^=]+)=(?P"?)(?P.+)(?P=quotechar)$', line) + if matches != None: + self.config[matches.group('key')] = matches.group('value') def get_config(self): return self.config -- cgit v1.2.3-24-g4f1b