Merge pull request #82 from petronny/master
added use_last_modified for aur
This commit is contained in:
commit
0848d0a5d7
|
@ -2,6 +2,7 @@
|
||||||
# Copyright (c) 2013-2017 lilydjwg <lilydjwg@gmail.com>, et al.
|
# Copyright (c) 2013-2017 lilydjwg <lilydjwg@gmail.com>, et al.
|
||||||
|
|
||||||
import structlog
|
import structlog
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
from . import session
|
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):
|
async def get_version(name, conf, **kwargs):
|
||||||
aurname = conf.get('aur') or name
|
aurname = conf.get('aur') or name
|
||||||
|
use_last_modified = conf.getboolean('use_last_modified', False)
|
||||||
strip_release = conf.getboolean('strip-release', False)
|
strip_release = conf.getboolean('strip-release', False)
|
||||||
async with session.get(AUR_URL, params={"v": 5, "type": "info", "arg[]": aurname}) as res:
|
async with session.get(AUR_URL, params={"v": 5, "type": "info", "arg[]": aurname}) as res:
|
||||||
data = await res.json()
|
data = await res.json()
|
||||||
|
@ -20,6 +22,8 @@ async def get_version(name, conf, **kwargs):
|
||||||
return
|
return
|
||||||
|
|
||||||
version = data['results'][0]['Version']
|
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:
|
if strip_release and '-' in version:
|
||||||
version = version.rsplit('-', 1)[0]
|
version = version.rsplit('-', 1)[0]
|
||||||
return version
|
return version
|
||||||
|
|
|
@ -12,3 +12,7 @@ async def test_aur(get_version):
|
||||||
@flaky(max_runs=10)
|
@flaky(max_runs=10)
|
||||||
async def test_aur_strip_release(get_version):
|
async def test_aur_strip_release(get_version):
|
||||||
assert await get_version("ssed", {"aur": None, "strip-release": 1}) == "3.62"
|
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"
|
||||||
|
|
Loading…
Reference in New Issue