Simplify a bit the loop to read our config file

- split the one-liner into a for and an if
- use open() as a context manager
- don't use string.strip which is gone in python3

Signed-off-by: Julien Cristau <jcristau@debian.org>
debian
Julien Cristau 10 years ago committed by Niels Thykier
parent 58a6a6ed1d
commit 94666b55f9

@ -364,7 +364,12 @@ class Britney(object):
# are handled as an ad-hoc case
self.MINDAYS = {}
self.HINTS = {'command-line': self.HINTS_ALL}
for k, v in [map(string.strip,r.split('=', 1)) for r in open(self.options.config) if '=' in r and not r.strip().startswith('#')]:
with open(self.options.config) as config:
for line in config:
if '=' in line and not line.strip().startswith('#'):
k, v = line.split('=', 1)
k = k.strip()
v = v.strip()
if k.startswith("MINDAYS_"):
self.MINDAYS[k.split("_")[1].lower()] = int(v)
elif k.startswith("HINTS_"):

Loading…
Cancel
Save