Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib
diff options
context:
space:
mode:
authorAnton Hvornum <anton.feeds+github@gmail.com>2020-10-18 09:58:33 +0200
committerAnton Hvornum <anton.feeds+github@gmail.com>2020-10-18 09:58:33 +0200
commit1a10fe3f51f7555bf8c29046c707719d7dccb33c (patch)
treedf39147ea4c5afeab1e9bc3a8f38321767634ba0 /archinstall/lib
parent60aaae4337c90bea3d485f58f7ab206cb1539a74 (diff)
Implementing error handling for #50. So that the errors do not come at the very end, but in the beginning right after the user inputted something (quicker feedback to the user).
Diffstat (limited to 'archinstall/lib')
-rw-r--r--archinstall/lib/packages.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/archinstall/lib/packages.py b/archinstall/lib/packages.py
index 3a671784..29728abc 100644
--- a/archinstall/lib/packages.py
+++ b/archinstall/lib/packages.py
@@ -1,5 +1,6 @@
import urllib.request, urllib.parse
import ssl, json
+from .lib.exceptions import *
BASE_URL = 'https://www.archlinux.org/packages/search/json/?name={package}'
@@ -24,4 +25,19 @@ def find_packages(*names):
result = {}
for package in names:
result[package] = find_package(package)
- return result \ No newline at end of file
+ return result
+
+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']:
+ invalid_packages.append(package)
+
+ if invalid_packages:
+ raise RequirementError(f"Invalid package names: {invalid_packages}")
+
+ return True \ No newline at end of file