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:
Lubomír Sedlář 2016-11-09 13:39:01 +01:00
parent bd00920c62
commit 13871b64fb
9 changed files with 18 additions and 11 deletions

View File

@ -366,7 +366,7 @@ def run_compose(compose, create_latest_link=True):
pungi.metadata.write_tree_info(compose, arch, variant)
# 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:
continue
for arch in variant.arches + ["src"]:

View File

@ -229,13 +229,13 @@ class Compose(kobo.log.LoggingBase):
#### or if it is at all
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 = []
types = types or ["variant", "optional", "addon", "layered-product"]
for i in self.variants.itervalues():
if i.type in types and (not arch or arch in i.arches):
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))
def get_arches(self):

View File

@ -65,7 +65,7 @@ class CreateisoPhase(PhaseBase):
deliverables = []
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"]:
skip_iso = get_arch_variant_data(self.compose.conf, "createiso_skip", arch, variant)
if skip_iso == [True]:

View File

@ -307,7 +307,7 @@ def gather_wrapper(compose, package_sets, path_prefix):
# write packages (package lists) for all variants
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]
write_packages(compose, arch, variant, pkg_map, path_prefix=path_prefix)

View File

@ -60,10 +60,6 @@ class DummyCompose(object):
type='variant', is_empty=False),
}
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_error = mock.Mock()
self.log_debug = mock.Mock()
@ -78,8 +74,14 @@ class DummyCompose(object):
self.fail_deliverable = mock.Mock()
self.require_deliverable = mock.Mock()
def get_variants(self, arch=None, types=None, recursive=None):
return [v for v in self.variants.values() if not arch or arch in v.arches]
def setup_optional(self):
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):
failable = get_arch_variant_data(self.conf, 'failable_deliverables', arch, variant)

View File

@ -28,6 +28,7 @@ class BuildInstallCompose(DummyCompose):
type='variant', buildinstallpackages=[],
is_empty=False),
}
self.all_variants = self.variants.copy()
class TestBuildinstallPhase(PungiTestCase):

View File

@ -284,6 +284,7 @@ class TestImageBuildPhase(PungiTestCase):
},
'koji_profile': 'koji',
})
compose.setup_optional()
self.assertEqual(validate(compose.conf), [])
@ -347,6 +348,7 @@ class TestImageBuildPhase(PungiTestCase):
},
'koji_profile': 'koji',
})
compose.setup_optional()
self.assertEqual(validate(compose.conf), [])

View File

@ -31,6 +31,7 @@ class TestLiveImagesPhase(PungiTestCase):
})
],
})
compose.setup_optional()
self.assertEqual(validate(compose.conf), [])

View File

@ -338,6 +338,7 @@ class TestLiveMediaPhase(PungiTestCase):
]
}
})
compose.setup_optional()
self.assertEqual(validate(compose.conf), [])