Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/models
diff options
context:
space:
mode:
Diffstat (limited to 'archinstall/lib/models')
-rw-r--r--archinstall/lib/models/gen.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/archinstall/lib/models/gen.py b/archinstall/lib/models/gen.py
index cc8d7605..fb7e5751 100644
--- a/archinstall/lib/models/gen.py
+++ b/archinstall/lib/models/gen.py
@@ -1,5 +1,5 @@
from dataclasses import dataclass
-from typing import Optional, List
+from typing import Optional, List, Dict, Any
@dataclass
@@ -87,6 +87,10 @@ class PackageSearchResult:
makedepends: List[str]
checkdepends: List[str]
+ @staticmethod
+ def from_json(data: Dict[str, Any]) -> 'PackageSearchResult':
+ return PackageSearchResult(**data)
+
@property
def pkg_version(self) -> str:
return self.pkgver
@@ -107,8 +111,18 @@ class PackageSearch:
page: int
results: List[PackageSearchResult]
- def __post_init__(self):
- self.results = [PackageSearchResult(**x) for x in self.results]
+ @staticmethod
+ def from_json(data: Dict[str, Any]) -> 'PackageSearch':
+ results = [PackageSearchResult.from_json(r) for r in data['results']]
+
+ return PackageSearch(
+ version=data['version'],
+ limit=data['limit'],
+ valid=data['valid'],
+ num_pages=data['num_pages'],
+ page=data['page'],
+ results=results
+ )
@dataclass