mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 01:14:15 +02:00
fix: AUR installation receiving GPG key
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
import re
|
||||
from typing import Set, List
|
||||
|
||||
import requests
|
||||
|
||||
from bauh.api.http import HttpClient
|
||||
|
||||
URL_INFO = 'https://aur.archlinux.org/rpc/?v=5&type=info&'
|
||||
URL_SRC_INFO = 'https://aur.archlinux.org/cgit/aur.git/plain/.SRCINFO?h='
|
||||
URL_SEARCH = 'https://aur.archlinux.org/rpc/?v=5&type=search&arg='
|
||||
|
||||
RE_SRCINFO_KEYS = re.compile(r'(\w+)\s+=\s+(.+)\n')
|
||||
|
||||
|
||||
def map_pkgbuild(pkgbuild: str) -> dict:
|
||||
return {attr: val.replace('"', '').replace("'", '').replace('(', '').replace(')', '') for attr, val in re.findall(r'\n(\w+)=(.+)', pkgbuild)}
|
||||
@@ -24,5 +29,24 @@ class AURClient:
|
||||
res = self.http_client.get_json(URL_INFO + self._map_names_as_queries(names))
|
||||
return res['results'] if res and res.get('results') else []
|
||||
|
||||
def get_src_info(self, name: str) -> dict:
|
||||
res = self.http_client.get(URL_SRC_INFO + name)
|
||||
|
||||
if res and res.text:
|
||||
info = {}
|
||||
for field in RE_SRCINFO_KEYS.findall(res.text):
|
||||
if field[0] not in info:
|
||||
info[field[0]] = field[1]
|
||||
else:
|
||||
if not isinstance(info[field[0]], list):
|
||||
info[field[0]] = [info[field[0]]]
|
||||
|
||||
info[field[0]].append(field[1])
|
||||
|
||||
if info.get('validpgpkeys') and isinstance(info['validpgpkeys'], str):
|
||||
info['validpgpkeys'] = [info['validpgpkeys']]
|
||||
|
||||
return info
|
||||
|
||||
def _map_names_as_queries(self, names) -> str:
|
||||
return '&'.join(['arg[{}]={}'.format(i, n) for i, n in enumerate(names)])
|
||||
|
||||
Reference in New Issue
Block a user