diff --git a/nvchecker/source/aur.py b/nvchecker/source/aur.py index f33612d..fc4b0eb 100644 --- a/nvchecker/source/aur.py +++ b/nvchecker/source/aur.py @@ -2,6 +2,7 @@ # Copyright (c) 2013-2017 lilydjwg , 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 diff --git a/tests/test_aur.py b/tests/test_aur.py index 2b67adb..331528e 100644 --- a/tests/test_aur.py +++ b/tests/test_aur.py @@ -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"