hints.py codestyle fixes

ubuntu/rebased
Ivo De Decker 5 years ago
parent 976accaf57
commit 0c66464fd5

@ -32,25 +32,24 @@ class HintCollection(object):
def __getitem__(self, type=None): def __getitem__(self, type=None):
return self.search(type) return self.search(type)
def search(self, type=None, onlyactive=True, package=None, \ def search(self, type=None, onlyactive=True, package=None,
version=None, architecture=None, suite=None, removal=None): version=None, architecture=None, suite=None, removal=None):
return [ hint for hint in self._hints if return [hint for hint in self._hints if
(type is None or type == hint.type) and (type is None or type == hint.type) and
(hint.active or not onlyactive) and (hint.active or not onlyactive) and
(package is None or package == hint.packages[0].package) and (package is None or package == hint.packages[0].package) and
(version is None or version == hint.packages[0].version) and (version is None or version == hint.packages[0].version) and
(architecture is None or architecture == hint.packages[0].architecture) and (architecture is None or architecture == hint.packages[0].architecture) and
(suite is None or suite == hint.packages[0].suite) and (suite is None or suite == hint.packages[0].suite) and
(removal is None or removal == hint.packages[0].is_removal) (removal is None or removal == hint.packages[0].is_removal)]
]
def add_hint(self, hint): def add_hint(self, hint):
self._hints.append(hint) self._hints.append(hint)
class Hint(object): class Hint(object):
NO_VERSION = [ 'block', 'block-all', 'block-udeb', 'allow-archall-maintainer-upload', 'allow-uninst' ] NO_VERSION = ['block', 'block-all', 'block-udeb', 'allow-archall-maintainer-upload', 'allow-uninst']
def __init__(self, user, hint_type, packages): def __init__(self, user, hint_type, packages):
self._user = user self._user = user
@ -226,11 +225,11 @@ class HintParser(object):
line_no += 1 line_no += 1
if line == "" or line.startswith('#'): if line == "" or line.startswith('#'):
continue continue
l = line.split() ln = line.split()
hint_name = l[0] hint_name = ln[0]
if hint_name in aliases: if hint_name in aliases:
hint_name = aliases[hint_name] hint_name = aliases[hint_name]
l[0] = hint_name ln[0] = hint_name
if hint_name == 'finished': if hint_name == 'finished':
break break
if hint_name not in hint_table: if hint_name not in hint_table:
@ -242,12 +241,12 @@ class HintParser(object):
hint_name, who, filename, line_no, reason) hint_name, who, filename, line_no, reason)
continue continue
min_args, hint_parser_impl = hint_table[hint_name] min_args, hint_parser_impl = hint_table[hint_name]
if len(l) - 1 < min_args: if len(ln) - 1 < min_args:
self.logger.warning("Malformed hint found in %s (line %d): Needs at least %d argument(s), got %d", self.logger.warning("Malformed hint found in %s (line %d): Needs at least %d argument(s), got %d",
filename, line_no, min_args, len(l) - 1) filename, line_no, min_args, len(ln) - 1)
continue continue
try: try:
hint_parser_impl(mi_factory, hints, who, *l) hint_parser_impl(mi_factory, hints, who, *ln)
except MalformedHintException as e: except MalformedHintException as e:
self.logger.warning("Malformed hint found in %s (line %d): \"%s\"", filename, line_no, e.args[0]) self.logger.warning("Malformed hint found in %s (line %d): \"%s\"", filename, line_no, e.args[0])
continue continue

@ -13,7 +13,7 @@ EXCEPTIONS_BY_FILE = {
'britney.py': 0, 'britney.py': 0,
'britney2/excuse.py': 0, 'britney2/excuse.py': 0,
'britney2/excusefinder.py': 0, 'britney2/excusefinder.py': 0,
'britney2/hints.py': 8, 'britney2/hints.py': 0,
'britney2/installability/tester.py': 4, 'britney2/installability/tester.py': 4,
'britney2/policies/__init__.py': 0, 'britney2/policies/__init__.py': 0,
'britney2/policies/policy.py': 0, 'britney2/policies/policy.py': 0,

Loading…
Cancel
Save