mirror of
https://github.com/lilydjwg/nvchecker.git
synced 2025-03-10 06:14:02 +00:00
add new source: archpkg
This commit is contained in:
parent
81a17ef690
commit
819a2c69d3
2 changed files with 26 additions and 1 deletions
|
@ -3,7 +3,7 @@ from importlib import import_module
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
handler_precedence = (
|
handler_precedence = (
|
||||||
'github', 'aur', 'pypi', 'pacman',
|
'github', 'aur', 'pypi', 'archpkg', 'pacman',
|
||||||
'cmd', 'gcode_hg', 'regex',
|
'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…
Add table
Reference in a new issue