From 4731acd9aa6a84c8ffaf32d4b85c2654d3118c37 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Mon, 8 Jan 2024 13:47:50 -0800 Subject: [PATCH] Make _LEAPP_DEFAULT_COMPONENTS global immutable. Making this value immutable has two benefits: * Users won't accidentally modify this if they're looking for an easy way to pass a slight modification to the default components. * We can use it directly as the default parameter value in the get_leapp_packages() function definition. I think we should also make this variable public so users are encouraged to use this for making minor modifications but we don't have agreement on the name yet. So I'll do that in a separate commit or we can do it in a future PR. --- repos/system_upgrade/common/libraries/rpms.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/repos/system_upgrade/common/libraries/rpms.py b/repos/system_upgrade/common/libraries/rpms.py index d378f2e7c3..b8ba9e5ff8 100644 --- a/repos/system_upgrade/common/libraries/rpms.py +++ b/repos/system_upgrade/common/libraries/rpms.py @@ -36,9 +36,10 @@ class LeappComponents(object): '8': {'pkgs': ['snactor']} } } -_LEAPP_DEFAULT_COMPONENTS = [LeappComponents.FRAMEWORK, - LeappComponents.REPOSITORY, - LeappComponents.TOOLS] + +_LEAPP_DEFAULT_COMPONENTS = frozenset((LeappComponents.FRAMEWORK, + LeappComponents.REPOSITORY, + LeappComponents.TOOLS)) def get_installed_rpms(): @@ -155,7 +156,7 @@ def check_file_modification(config): return _parse_config_modification(output, config) -def get_leapp_packages(major_version=None, component=None, include_deps=False): +def get_leapp_packages(major_version=None, component=_LEAPP_DEFAULT_COMPONENTS, include_deps=False): """ Get list of leapp packages. @@ -174,9 +175,6 @@ def get_leapp_packages(major_version=None, component=None, include_deps=False): # requested major_versions = [get_source_major_version()] components = [component] if isinstance(component, str) else component - if not component: - # No component of interest specified -> return default leapp components - components = _LEAPP_DEFAULT_COMPONENTS for comp in components: for a_major_version in major_versions: if comp not in _LEAPP_PACKAGES_MAP: