Merge branch 'master' of github.com:lilydjwg/nvchecker

This commit is contained in:
lilydjwg 2018-09-30 19:50:27 +08:00
commit faf14b64c4
2 changed files with 8 additions and 0 deletions

View File

@ -2,6 +2,7 @@
# Copyright (c) 2013-2017 lilydjwg <lilydjwg@gmail.com>, et al.
import structlog
from datetime import datetime
from . import session
@ -11,6 +12,7 @@ AUR_URL = 'https://aur.archlinux.org/rpc/?v=5&type=info&arg[]='
async def get_version(name, conf, **kwargs):
aurname = conf.get('aur') or name
use_last_modified = conf.getboolean('use_last_modified', False)
strip_release = conf.getboolean('strip-release', False)
async with session.get(AUR_URL, params={"v": 5, "type": "info", "arg[]": aurname}) as res:
data = await res.json()
@ -20,6 +22,8 @@ async def get_version(name, conf, **kwargs):
return
version = data['results'][0]['Version']
if use_last_modified:
version += '-' + datetime.utcfromtimestamp(data['results'][0]['LastModified']).strftime('%Y%m%d%H%M%S')
if strip_release and '-' in version:
version = version.rsplit('-', 1)[0]
return version

View File

@ -12,3 +12,7 @@ async def test_aur(get_version):
@flaky(max_runs=10)
async def test_aur_strip_release(get_version):
assert await get_version("ssed", {"aur": None, "strip-release": 1}) == "3.62"
@flaky(max_runs=10)
async def test_aur_use_last_modified(get_version):
assert await get_version("ssed", {"aur": None, 'use_last_modified': True}) == "3.62-2-20150725052412"