inst/builder.py: Split function in three to reduce indentation levels

Signed-off-by: Niels Thykier <niels@thykier.net>
ubuntu/rebased
Niels Thykier 6 years ago
parent dd5211d55a
commit 1e46965924
No known key found for this signature in database
GPG Key ID: A65B78DBE67C7AAC

@ -23,13 +23,19 @@ from britney2.installability.solver import InstallabilitySolver
def build_installability_tester(suite_info, archs): def build_installability_tester(suite_info, archs):
"""Create the installability tester""" """Create the installability tester"""
solvers = get_dependency_solvers
builder = InstallabilityTesterBuilder() builder = InstallabilityTesterBuilder()
for (suite, arch) in product(suite_info, archs): for (suite, arch) in product(suite_info, archs):
_build_inst_tester_on_suite_arch(builder, suite_info, suite, arch)
return builder.build()
def _build_inst_tester_on_suite_arch(builder, suite_info, suite, arch):
packages_s_a = suite.binaries[arch][0] packages_s_a = suite.binaries[arch][0]
is_target = suite.suite_class.is_target is_target = suite.suite_class.is_target
bin_prov = [s.binaries[arch] for s in suite_info] bin_prov = [s.binaries[arch] for s in suite_info]
solvers = get_dependency_solvers
for pkgdata in packages_s_a.values(): for pkgdata in packages_s_a.values():
pkg_id = pkgdata.pkg_id pkg_id = pkgdata.pkg_id
if not builder.add_binary(pkg_id, if not builder.add_binary(pkg_id,
@ -51,6 +57,14 @@ def build_installability_tester(suite_info, archs):
conflicts = None conflicts = None
if pkgdata.depends: if pkgdata.depends:
depends = _compute_depends(pkgdata, bin_prov, solvers)
else:
depends = None
builder.set_relations(pkg_id, depends, conflicts)
def _compute_depends(pkgdata, bin_prov, solvers):
depends = [] depends = []
possible_dep_ranges = {} possible_dep_ranges = {}
for block in apt_pkg.parse_depends(pkgdata.depends, False): for block in apt_pkg.parse_depends(pkgdata.depends, False):
@ -87,12 +101,8 @@ def build_installability_tester(suite_info, archs):
if possible_dep_ranges: if possible_dep_ranges:
depends.extend(possible_dep_ranges.values()) depends.extend(possible_dep_ranges.values())
else:
depends = None
builder.set_relations(pkg_id, depends, conflicts)
return builder.build() return depends
class InstallabilityTesterBuilder(object): class InstallabilityTesterBuilder(object):

Loading…
Cancel
Save