index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
author | Andreas Baumann <mail@andreasbaumann.cc> | 2024-05-10 15:56:28 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2024-05-10 15:56:28 +0200 |
commit | 683da22298abbd90f51d4dd38a7ec4b0dfb04555 (patch) | |
tree | ec2ac04967f9277df038edc362201937b331abe5 /archinstall/lib/packages | |
parent | af7ab9833c9f9944874f0162ae0975175ddc628d (diff) | |
parent | 3381cd55673e5105697d354cf4a1be9a7bcef062 (diff) |
-rw-r--r-- | archinstall/lib/packages/__init__.py | 4 | ||||
-rw-r--r-- | archinstall/lib/packages/packages.py | 14 |
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 |