add Anitya support

This commit is contained in:
lilydjwg 2017-07-25 15:23:54 +08:00
parent c3503c34ac
commit 2d2f7149aa
3 changed files with 28 additions and 1 deletions

View file

@ -9,7 +9,8 @@ handler_precedence = (
'github', 'aur', 'pypi', 'archpkg', 'debianpkg', 'ubuntupkg',
'gems', 'pacman',
'cmd', 'bitbucket', 'regex', 'manual', 'vcs',
'cratesio', 'npm', 'hackage', 'cpan', 'gitlab', 'packagist'
'cratesio', 'npm', 'hackage', 'cpan', 'gitlab', 'packagist',
'anitya',
)
async def get_version(name, conf):

View file

@ -0,0 +1,18 @@
# MIT licensed
# Copyright (c) 2017 lilydjwg <lilydjwg@gmail.com>, et al.
import logging
from . import session
logger = logging.getLogger(__name__)
URL = 'https://release-monitoring.org/api/project/{pkg}'
async def get_version(name, conf):
pkg = conf.get('anitya')
url = URL.format(pkg = pkg)
async with session.get(url) as res:
data = await res.json()
return data['version']

8
tests/test_anitya.py Normal file
View file

@ -0,0 +1,8 @@
# MIT licensed
# Copyright (c) 2017 Felix Yan <felixonmars@archlinux.org>, et al.
import pytest
pytestmark = pytest.mark.asyncio
async def test_anitya(get_version):
assert await get_version("shutter", {"anitya": "fedora/shutter"}) == "0.93.1"