From 3d4f58a04e06ef4bdd023effc52d4cb33b49080c Mon Sep 17 00:00:00 2001 From: monosans Date: Fri, 16 Jul 2021 10:42:29 +0300 Subject: Replace for loops with comprehensions --- archinstall/lib/packages.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'archinstall/lib/packages.py') diff --git a/archinstall/lib/packages.py b/archinstall/lib/packages.py index 0ea195d2..0178d257 100644 --- a/archinstall/lib/packages.py +++ b/archinstall/lib/packages.py @@ -46,10 +46,7 @@ def find_packages(*names): The function itself is rather slow, so consider not sending to many packages to the search query. """ - result = {} - for package in names: - result[package] = find_package(package) - return result + return {package: find_package(package) for package in names} def validate_package_list(packages: list): @@ -57,11 +54,11 @@ def validate_package_list(packages: list): Validates a list of given packages. Raises `RequirementError` if one or more packages are not found. """ - invalid_packages = [] - for package in packages: - if not find_package(package)['results'] and not find_group(package): - invalid_packages.append(package) - + invalid_packages = [ + package + for package in packages + if not find_package(package)['results'] and not find_group(package) + ] if invalid_packages: raise RequirementError(f"Invalid package names: {invalid_packages}") -- cgit v1.2.3-70-g09d2