mirror of
https://github.com/lilydjwg/nvchecker
synced 2025-01-04 05:12:17 +00:00
add new source: archpkg
This commit is contained in:
parent
81a17ef690
commit
819a2c69d3
@ -3,7 +3,7 @@ from importlib import import_module
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
handler_precedence = (
|
||||
'github', 'aur', 'pypi', 'pacman',
|
||||
'github', 'aur', 'pypi', 'archpkg', 'pacman',
|
||||
'cmd', 'gcode_hg', 'regex',
|
||||
)
|
||||
|
||||
|
25
nvchecker/source/archpkg.py
Normal file
25
nvchecker/source/archpkg.py
Normal file
@ -0,0 +1,25 @@
|
||||
from functools import partial
|
||||
import json
|
||||
|
||||
from tornado.httpclient import AsyncHTTPClient
|
||||
|
||||
URL = 'https://www.archlinux.org/packages/search/json/?name='
|
||||
|
||||
def get_version(name, conf, callback):
|
||||
pkg = conf['archpkg']
|
||||
url = URL + pkg
|
||||
AsyncHTTPClient().fetch(url, partial(_pkg_done, name, callback))
|
||||
|
||||
def _pkg_done(name, callback, res):
|
||||
if res.error:
|
||||
raise res.error
|
||||
|
||||
data = json.loads(res.body.decode('utf-8'))
|
||||
|
||||
if not data['results']:
|
||||
logger.error('Arch package not found: %s', name)
|
||||
callback(name, None)
|
||||
return
|
||||
|
||||
version = data['results'][0]['pkgver']
|
||||
callback(name, version)
|
Loading…
Reference in New Issue
Block a user