mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-05-28 19:01:35 +00:00
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>
This commit is contained in:
parent
b64afb639f
commit
49475f79ba
23
britney.py
23
britney.py
@ -364,15 +364,20 @@ class Britney(object):
|
|||||||
# are handled as an ad-hoc case
|
# are handled as an ad-hoc case
|
||||||
self.MINDAYS = {}
|
self.MINDAYS = {}
|
||||||
self.HINTS = {'command-line': self.HINTS_ALL}
|
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:
|
||||||
if k.startswith("MINDAYS_"):
|
for line in config:
|
||||||
self.MINDAYS[k.split("_")[1].lower()] = int(v)
|
if '=' in line and not line.strip().startswith('#'):
|
||||||
elif k.startswith("HINTS_"):
|
k, v = line.split('=', 1)
|
||||||
self.HINTS[k.split("_")[1].lower()] = \
|
k = k.strip()
|
||||||
reduce(lambda x,y: x+y, [hasattr(self, "HINTS_" + i) and getattr(self, "HINTS_" + i) or (i,) for i in v.split()])
|
v = v.strip()
|
||||||
elif not hasattr(self.options, k.lower()) or \
|
if k.startswith("MINDAYS_"):
|
||||||
not getattr(self.options, k.lower()):
|
self.MINDAYS[k.split("_")[1].lower()] = int(v)
|
||||||
setattr(self.options, k.lower(), v)
|
elif k.startswith("HINTS_"):
|
||||||
|
self.HINTS[k.split("_")[1].lower()] = \
|
||||||
|
reduce(lambda x,y: x+y, [hasattr(self, "HINTS_" + i) and getattr(self, "HINTS_" + i) or (i,) for i in v.split()])
|
||||||
|
elif not hasattr(self.options, k.lower()) or \
|
||||||
|
not getattr(self.options, k.lower()):
|
||||||
|
setattr(self.options, k.lower(), v)
|
||||||
|
|
||||||
if not hasattr(self.options, "heidi_delta_output"):
|
if not hasattr(self.options, "heidi_delta_output"):
|
||||||
self.options.heidi_delta_output = self.options.heidi_output + "Delta"
|
self.options.heidi_delta_output = self.options.heidi_output + "Delta"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user