compose: Drop unused argument
The `get_variants()` method had a `recursive` argument with default value of `False. However, this argument had no effect and the method always returned all variants recursively. We can just drop the argument. All callers are updated to not supply the argument. Should any need for getting the top-level variants only arise, they can be accessed as the `variants` attribute directly on the Compose object. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
bd00920c62
commit
13871b64fb
@ -366,7 +366,7 @@ def run_compose(compose, create_latest_link=True):
|
|||||||
pungi.metadata.write_tree_info(compose, arch, variant)
|
pungi.metadata.write_tree_info(compose, arch, variant)
|
||||||
|
|
||||||
# write .discinfo and media.repo before ISOs are created
|
# write .discinfo and media.repo before ISOs are created
|
||||||
for variant in compose.get_variants(recursive=True):
|
for variant in compose.get_variants():
|
||||||
if variant.type == "addon" or variant.is_empty:
|
if variant.type == "addon" or variant.is_empty:
|
||||||
continue
|
continue
|
||||||
for arch in variant.arches + ["src"]:
|
for arch in variant.arches + ["src"]:
|
||||||
|
@ -229,13 +229,13 @@ class Compose(kobo.log.LoggingBase):
|
|||||||
#### or if it is at all
|
#### or if it is at all
|
||||||
self.ci_base = compose_to_composeinfo(self)
|
self.ci_base = compose_to_composeinfo(self)
|
||||||
|
|
||||||
def get_variants(self, types=None, arch=None, recursive=False):
|
def get_variants(self, types=None, arch=None):
|
||||||
result = []
|
result = []
|
||||||
types = types or ["variant", "optional", "addon", "layered-product"]
|
types = types or ["variant", "optional", "addon", "layered-product"]
|
||||||
for i in self.variants.itervalues():
|
for i in self.variants.itervalues():
|
||||||
if i.type in types and (not arch or arch in i.arches):
|
if i.type in types and (not arch or arch in i.arches):
|
||||||
result.append(i)
|
result.append(i)
|
||||||
result.extend(i.get_variants(types=types, arch=arch, recursive=recursive))
|
result.extend(i.get_variants(types=types, arch=arch))
|
||||||
return sorted(set(result))
|
return sorted(set(result))
|
||||||
|
|
||||||
def get_arches(self):
|
def get_arches(self):
|
||||||
|
@ -65,7 +65,7 @@ class CreateisoPhase(PhaseBase):
|
|||||||
deliverables = []
|
deliverables = []
|
||||||
|
|
||||||
commands = []
|
commands = []
|
||||||
for variant in self.compose.get_variants(types=["variant", "layered-product", "optional"], recursive=True):
|
for variant in self.compose.get_variants(types=["variant", "layered-product", "optional"]):
|
||||||
for arch in variant.arches + ["src"]:
|
for arch in variant.arches + ["src"]:
|
||||||
skip_iso = get_arch_variant_data(self.compose.conf, "createiso_skip", arch, variant)
|
skip_iso = get_arch_variant_data(self.compose.conf, "createiso_skip", arch, variant)
|
||||||
if skip_iso == [True]:
|
if skip_iso == [True]:
|
||||||
|
@ -307,7 +307,7 @@ def gather_wrapper(compose, package_sets, path_prefix):
|
|||||||
|
|
||||||
# write packages (package lists) for all variants
|
# write packages (package lists) for all variants
|
||||||
for arch in compose.get_arches():
|
for arch in compose.get_arches():
|
||||||
for variant in compose.get_variants(arch=arch, recursive=True):
|
for variant in compose.get_variants(arch=arch):
|
||||||
pkg_map = result[arch][variant.uid]
|
pkg_map = result[arch][variant.uid]
|
||||||
write_packages(compose, arch, variant, pkg_map, path_prefix=path_prefix)
|
write_packages(compose, arch, variant, pkg_map, path_prefix=path_prefix)
|
||||||
|
|
||||||
|
@ -60,10 +60,6 @@ class DummyCompose(object):
|
|||||||
type='variant', is_empty=False),
|
type='variant', is_empty=False),
|
||||||
}
|
}
|
||||||
self.all_variants = self.variants.copy()
|
self.all_variants = self.variants.copy()
|
||||||
self.all_variants['Server-optional'] = mock.Mock(
|
|
||||||
uid='Server-optional', arches=['x86_64'], type='optional', is_empty=False,
|
|
||||||
parent=self.variants['Server'])
|
|
||||||
self.variants['Server'].variants = {'optional': self.all_variants['Server-optional']}
|
|
||||||
self.log_info = mock.Mock()
|
self.log_info = mock.Mock()
|
||||||
self.log_error = mock.Mock()
|
self.log_error = mock.Mock()
|
||||||
self.log_debug = mock.Mock()
|
self.log_debug = mock.Mock()
|
||||||
@ -78,8 +74,14 @@ class DummyCompose(object):
|
|||||||
self.fail_deliverable = mock.Mock()
|
self.fail_deliverable = mock.Mock()
|
||||||
self.require_deliverable = mock.Mock()
|
self.require_deliverable = mock.Mock()
|
||||||
|
|
||||||
def get_variants(self, arch=None, types=None, recursive=None):
|
def setup_optional(self):
|
||||||
return [v for v in self.variants.values() if not arch or arch in v.arches]
|
self.all_variants['Server-optional'] = mock.Mock(
|
||||||
|
uid='Server-optional', arches=['x86_64'], type='optional', is_empty=False,
|
||||||
|
parent=self.variants['Server'])
|
||||||
|
self.variants['Server'].variants = {'optional': self.all_variants['Server-optional']}
|
||||||
|
|
||||||
|
def get_variants(self, arch=None, types=None):
|
||||||
|
return [v for v in self.all_variants.values() if not arch or arch in v.arches]
|
||||||
|
|
||||||
def can_fail(self, variant, arch, deliverable):
|
def can_fail(self, variant, arch, deliverable):
|
||||||
failable = get_arch_variant_data(self.conf, 'failable_deliverables', arch, variant)
|
failable = get_arch_variant_data(self.conf, 'failable_deliverables', arch, variant)
|
||||||
|
@ -28,6 +28,7 @@ class BuildInstallCompose(DummyCompose):
|
|||||||
type='variant', buildinstallpackages=[],
|
type='variant', buildinstallpackages=[],
|
||||||
is_empty=False),
|
is_empty=False),
|
||||||
}
|
}
|
||||||
|
self.all_variants = self.variants.copy()
|
||||||
|
|
||||||
|
|
||||||
class TestBuildinstallPhase(PungiTestCase):
|
class TestBuildinstallPhase(PungiTestCase):
|
||||||
|
@ -284,6 +284,7 @@ class TestImageBuildPhase(PungiTestCase):
|
|||||||
},
|
},
|
||||||
'koji_profile': 'koji',
|
'koji_profile': 'koji',
|
||||||
})
|
})
|
||||||
|
compose.setup_optional()
|
||||||
|
|
||||||
self.assertEqual(validate(compose.conf), [])
|
self.assertEqual(validate(compose.conf), [])
|
||||||
|
|
||||||
@ -347,6 +348,7 @@ class TestImageBuildPhase(PungiTestCase):
|
|||||||
},
|
},
|
||||||
'koji_profile': 'koji',
|
'koji_profile': 'koji',
|
||||||
})
|
})
|
||||||
|
compose.setup_optional()
|
||||||
|
|
||||||
self.assertEqual(validate(compose.conf), [])
|
self.assertEqual(validate(compose.conf), [])
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ class TestLiveImagesPhase(PungiTestCase):
|
|||||||
})
|
})
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
compose.setup_optional()
|
||||||
|
|
||||||
self.assertEqual(validate(compose.conf), [])
|
self.assertEqual(validate(compose.conf), [])
|
||||||
|
|
||||||
|
@ -338,6 +338,7 @@ class TestLiveMediaPhase(PungiTestCase):
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
compose.setup_optional()
|
||||||
|
|
||||||
self.assertEqual(validate(compose.conf), [])
|
self.assertEqual(validate(compose.conf), [])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user