From d04202631477b551962d473b7fadef0da60e08d9 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Fri, 22 Feb 2019 16:10:53 -0800 Subject: [PATCH] setup: Abstraction for getting managing packages of a module Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/setup.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plinth/setup.py b/plinth/setup.py index 1f8894d70..581826462 100644 --- a/plinth/setup.py +++ b/plinth/setup.py @@ -184,7 +184,7 @@ class Helper(object): if num_files < 2: # not counting the lock file return None cache = apt.Cache() - managed_pkgs = getattr(self.module, 'managed_packages', []) + managed_pkgs = _get_module_managed_packages(self.module) unavailable_pkgs = (pkg_name for pkg_name in managed_pkgs if pkg_name not in cache) return any(unavailable_pkgs) @@ -227,7 +227,7 @@ def list_dependencies(module_list=None, essential=False): '*' not in module_list: continue - for package_name in getattr(module, 'managed_packages', []): + for package_name in _get_module_managed_packages(module): print(package_name) @@ -304,6 +304,11 @@ def _is_module_essential(module): return getattr(module, 'is_essential', False) +def _get_module_managed_packages(module): + """Return list of packages managed by a module.""" + return getattr(module, 'managed_packages', []) + + def _module_state_matches(module, state): """Return if the current setup state of a module matches given state.""" return module.setup_helper.get_state() == state