fix codestyle issues in policy_.py

ubuntu/rebased
Ivo De Decker 5 years ago
parent 5890cb914e
commit 19392f63c2

@ -428,11 +428,11 @@ class AgePolicy(BasePolicy):
# Ignore comment lines (mostly used for tests) # Ignore comment lines (mostly used for tests)
continue continue
# <source> <version> <date>) # <source> <version> <date>)
l = line.split() ln = line.split()
if len(l) != 3: # pragma: no cover if len(ln) != 3: # pragma: no cover
continue continue
try: try:
dates[l[0]] = (l[1], int(l[2])) dates[ln[0]] = (ln[1], int(ln[2]))
except ValueError: # pragma: no cover except ValueError: # pragma: no cover
pass pass
except FileNotFoundError: except FileNotFoundError:
@ -463,31 +463,31 @@ class AgePolicy(BasePolicy):
# Ignore comment lines (mostly used for tests) # Ignore comment lines (mostly used for tests)
continue continue
# <source> <version> <urgency> # <source> <version> <urgency>
l = line.split() ln = line.split()
if len(l) != 3: if len(ln) != 3:
continue continue
# read the minimum days associated with the urgencies # read the minimum days associated with the urgencies
urgency_old = urgencies.get(l[0], None) urgency_old = urgencies.get(ln[0], None)
mindays_old = self._min_days.get(urgency_old, 1000) mindays_old = self._min_days.get(urgency_old, 1000)
mindays_new = self._min_days.get(l[2], min_days_default) mindays_new = self._min_days.get(ln[2], min_days_default)
# if the new urgency is lower (so the min days are higher), do nothing # if the new urgency is lower (so the min days are higher), do nothing
if mindays_old <= mindays_new: if mindays_old <= mindays_new:
continue continue
# if the package exists in the target suite and it is more recent, do nothing # if the package exists in the target suite and it is more recent, do nothing
tsrcv = sources_t.get(l[0], None) tsrcv = sources_t.get(ln[0], None)
if tsrcv and apt_pkg.version_compare(tsrcv.version, l[1]) >= 0: if tsrcv and apt_pkg.version_compare(tsrcv.version, ln[1]) >= 0:
continue continue
# if the package doesn't exist in the primary source suite or it is older, do nothing # if the package doesn't exist in the primary source suite or it is older, do nothing
usrcv = sources_s.get(l[0], None) usrcv = sources_s.get(ln[0], None)
if not usrcv or apt_pkg.version_compare(usrcv.version, l[1]) < 0: if not usrcv or apt_pkg.version_compare(usrcv.version, ln[1]) < 0:
continue continue
# update the urgency for the package # update the urgency for the package
urgencies[l[0]] = l[2] urgencies[ln[0]] = ln[2]
def _write_dates_file(self): def _write_dates_file(self):
dates = self._dates dates = self._dates
@ -644,14 +644,14 @@ class RCBugPolicy(BasePolicy):
bugs = {} bugs = {}
self.logger.info("Loading RC bugs data from %s", filename) self.logger.info("Loading RC bugs data from %s", filename)
for line in open(filename, encoding='ascii'): for line in open(filename, encoding='ascii'):
l = line.split() ln = line.split()
if len(l) != 2: # pragma: no cover if len(ln) != 2: # pragma: no cover
self.logger.warning("Malformed line found in line %s", line) self.logger.warning("Malformed line found in line %s", line)
continue continue
pkg = l[0] pkg = ln[0]
if pkg not in bugs: if pkg not in bugs:
bugs[pkg] = set() bugs[pkg] = set()
bugs[pkg].update(l[1].split(",")) bugs[pkg].update(ln[1].split(","))
return bugs return bugs
@ -871,12 +871,12 @@ class BuildDependsPolicy(BasePolicy):
arch_results = {} arch_results = {}
result_archs = defaultdict(list) result_archs = defaultdict(list)
bestresult = BuildDepResult.FAILED bestresult = BuildDepResult.FAILED
check_archs = self._get_check_archs(relevant_archs,dep_type); check_archs = self._get_check_archs(relevant_archs, dep_type)
if not check_archs: if not check_archs:
# when the arch list is empty, we check the b-d on any arch, instead of all archs # when the arch list is empty, we check the b-d on any arch, instead of all archs
# this happens for Build-Depens on a source package that only produces arch: all binaries # this happens for Build-Depens on a source package that only produces arch: all binaries
any_arch_ok = True any_arch_ok = True
check_archs = self._get_check_archs(self.options.architectures,DependencyType.BUILD_DEPENDS_INDEP); check_archs = self._get_check_archs(self.options.architectures, DependencyType.BUILD_DEPENDS_INDEP)
for arch in check_archs: for arch in check_archs:
# retrieve the binary package from the specified suite and arch # retrieve the binary package from the specified suite and arch
@ -936,11 +936,15 @@ class BuildDependsPolicy(BasePolicy):
excuse.addhtml("Checking %s on %s" % (dep_type.get_description(), arch)) excuse.addhtml("Checking %s on %s" % (dep_type.get_description(), arch))
key = "check-%s-on-arch" % dep_type.get_reason() key = "check-%s-on-arch" % dep_type.get_reason()
build_deps_info[key] = arch build_deps_info[key] = arch
verdict = self._add_info_for_arch(arch, excuses_info, blockers, arch_results, dep_type, target_suite, source_suite, excuse, verdict) verdict = self._add_info_for_arch(
arch, excuses_info, blockers, arch_results,
dep_type, target_suite, source_suite, excuse, verdict)
else: else:
for arch in check_archs: for arch in check_archs:
verdict = self._add_info_for_arch(arch, excuses_info, blockers, arch_results, dep_type, target_suite, source_suite, excuse, verdict) verdict = self._add_info_for_arch(
arch, excuses_info, blockers, arch_results,
dep_type, target_suite, source_suite, excuse, verdict)
if unsat_bd: if unsat_bd:
build_deps_info['unsatisfiable-arch-build-depends'] = unsat_bd build_deps_info['unsatisfiable-arch-build-depends'] = unsat_bd
@ -1246,4 +1250,3 @@ class BuiltOnBuilddPolicy(BasePolicy):
signerinfo = json.load(fd) signerinfo = json.load(fd)
return signerinfo return signerinfo

@ -16,7 +16,7 @@ EXCEPTIONS_BY_FILE = {
'britney2/hints.py': 8, 'britney2/hints.py': 8,
'britney2/installability/tester.py': 4, 'britney2/installability/tester.py': 4,
'britney2/policies/__init__.py': 1, 'britney2/policies/__init__.py': 1,
'britney2/policies/policy.py': 19, 'britney2/policies/policy.py': 0,
'britney2/policies/autopkgtest.py': 0, 'britney2/policies/autopkgtest.py': 0,
'tests/mock_swift.py': 2, 'tests/mock_swift.py': 2,
'tests/__init__.py': 31, 'tests/__init__.py': 31,

Loading…
Cancel
Save