Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/packages.py
diff options
context:
space:
mode:
authorAnton Hvornum <anton.feeds@gmail.com>2021-05-21 09:56:42 +0200
committerAnton Hvornum <anton.feeds@gmail.com>2021-05-21 09:56:42 +0200
commitf9ec8f2a2791b68f26bc858ccd6dea88720ae7c2 (patch)
treeccb8ff9acc6bb3cadaa59b1f4db9a377a51da08a /archinstall/lib/packages.py
parent129ceaea8be14362e2b22cbbf8b83ae0e392d1e8 (diff)
parent54a693be4fa2fbce83fd894b5ac3b0909f3a1e10 (diff)
Merging in latest changes from master and resolved conflicts.
Diffstat (limited to 'archinstall/lib/packages.py')
-rw-r--r--archinstall/lib/packages.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/archinstall/lib/packages.py b/archinstall/lib/packages.py
index 4f6b6c61..0ea195d2 100644
--- a/archinstall/lib/packages.py
+++ b/archinstall/lib/packages.py
@@ -1,10 +1,15 @@
-import urllib.request, urllib.parse
-import ssl, json
+import json
+import ssl
+import urllib.error
+import urllib.parse
+import urllib.request
+
from .exceptions import *
BASE_URL = 'https://archlinux.org/packages/search/json/?name={package}'
BASE_GROUP_URL = 'https://archlinux.org/groups/x86_64/{group}/'
+
def find_group(name):
ssl_context = ssl.create_default_context()
ssl_context.check_hostname = False
@@ -16,11 +21,12 @@ def find_group(name):
return False
else:
raise err
-
+
# Just to be sure some code didn't slip through the exception
if response.code == 200:
return True
+
def find_package(name):
"""
Finds a specific package via the package database.
@@ -33,6 +39,7 @@ def find_package(name):
data = response.read().decode('UTF-8')
return json.loads(data)
+
def find_packages(*names):
"""
This function returns the search results for many packages.
@@ -44,7 +51,8 @@ def find_packages(*names):
result[package] = find_package(package)
return result
-def validate_package_list(packages :list):
+
+def validate_package_list(packages: list):
"""
Validates a list of given packages.
Raises `RequirementError` if one or more packages are not found.
@@ -53,8 +61,8 @@ def validate_package_list(packages :list):
for package in packages:
if not find_package(package)['results'] and not find_group(package):
invalid_packages.append(package)
-
+
if invalid_packages:
raise RequirementError(f"Invalid package names: {invalid_packages}")
- return True \ No newline at end of file
+ return True