Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/packages
diff options
context:
space:
mode:
Diffstat (limited to 'archinstall/lib/packages')
-rw-r--r--archinstall/lib/packages/__init__.py4
-rw-r--r--archinstall/lib/packages/packages.py14
2 files changed, 11 insertions, 7 deletions
diff --git a/archinstall/lib/packages/__init__.py b/archinstall/lib/packages/__init__.py
index e69de29b..e2aab577 100644
--- a/archinstall/lib/packages/__init__.py
+++ b/archinstall/lib/packages/__init__.py
@@ -0,0 +1,4 @@
+from .packages import (
+ group_search, package_search, find_package,
+ find_packages, validate_package_list, installed_package
+)
diff --git a/archinstall/lib/packages/packages.py b/archinstall/lib/packages/packages.py
index 0743e83b..e495b03f 100644
--- a/archinstall/lib/packages/packages.py
+++ b/archinstall/lib/packages/packages.py
@@ -7,8 +7,8 @@ from urllib.parse import urlencode
from urllib.request import urlopen
from ..exceptions import PackageError, SysCallError
-from ..models.dataclasses import PackageSearch, PackageSearchResult, LocalPackage
-from ..pacman import run_pacman
+from ..models.gen import PackageSearch, PackageSearchResult, LocalPackage
+from ..pacman import Pacman
BASE_URL_PKG_SEARCH = 'https://archlinux.org/packages/search/json/'
# BASE_URL_PKG_CONTENT = 'https://archlinux.org/packages/search/json/'
@@ -37,7 +37,7 @@ def group_search(name :str) -> List[PackageSearchResult]:
raise err
# Just to be sure some code didn't slip through the exception
- data = response.read().decode('UTF-8')
+ data = response.read().decode('utf-8')
return [PackageSearchResult(**package) for package in json.loads(data)['results']]
@@ -55,8 +55,8 @@ def package_search(package :str) -> PackageSearch:
raise PackageError(f"Could not locate package: [{response.code}] {response}")
data = response.read().decode('UTF-8')
-
- return PackageSearch(**json.loads(data))
+ json_data = json.loads(data)
+ return PackageSearch.from_json(json_data)
def find_package(package :str) -> List[PackageSearchResult]:
@@ -106,11 +106,11 @@ def validate_package_list(packages :list) -> Tuple[list, list]:
def installed_package(package :str) -> LocalPackage:
package_info = {}
try:
- for line in run_pacman(f"-Q --info {package}"):
+ for line in Pacman.run(f"-Q --info {package}"):
if b':' in line:
key, value = line.decode().split(':', 1)
package_info[key.strip().lower().replace(' ', '_')] = value.strip()
except SysCallError:
pass
- return LocalPackage({field.name: package_info.get(field.name) for field in dataclasses.fields(LocalPackage)})
+ return LocalPackage({field.name: package_info.get(field.name) for field in dataclasses.fields(LocalPackage)}) # type: ignore