mirror of
https://github.com/lilydjwg/nvchecker.git
synced 2025-03-10 06:14:02 +00:00
add strip-release config, closing #11
This commit is contained in:
parent
8a6fbf4a9a
commit
3dce06ca21
4 changed files with 29 additions and 5 deletions
|
@ -108,6 +108,9 @@ Check `Arch User Repository <https://aur.archlinux.org/>`_ for updates.
|
|||
aur
|
||||
The package name in AUR. If empty, use the name of software (the *section name*).
|
||||
|
||||
strip-release
|
||||
Strip the release part.
|
||||
|
||||
Check GitHub
|
||||
------------
|
||||
Check `GitHub <https://github.com/>`_ for updates. The version returned is in date format ``%Y%m%d``, e.g. ``20130701``.
|
||||
|
@ -163,6 +166,9 @@ This is used when you run ``nvchecker`` on an Arch Linux system and the program
|
|||
pacman
|
||||
The package name to reference to.
|
||||
|
||||
strip-release
|
||||
Strip the release part.
|
||||
|
||||
Check Arch Linux official packages
|
||||
----------------------------------
|
||||
This enables you to track the update of `Arch Linux official packages <https://www.archlinux.org/packages/>`_, without needing of pacman and an updated local Pacman databases.
|
||||
|
@ -170,6 +176,9 @@ This enables you to track the update of `Arch Linux official packages <https://w
|
|||
archpkg
|
||||
Name of the Arch Linux package.
|
||||
|
||||
strip-release
|
||||
Strip the release part.
|
||||
|
||||
Check Google Code (hg repository)
|
||||
---------------------------------
|
||||
Check a mercurial (hg) repository on `Google Code <https://code.google.com/>`_ for updates. The version returned is in date format ``%Y%m%d``, e.g. ``20130701``.
|
||||
|
|
|
@ -7,10 +7,12 @@ URL = 'https://www.archlinux.org/packages/search/json/?name='
|
|||
|
||||
def get_version(name, conf, callback):
|
||||
pkg = conf['archpkg']
|
||||
strip_release = conf.getboolean('strip-release', False)
|
||||
url = URL + pkg
|
||||
AsyncHTTPClient().fetch(url, partial(_pkg_done, name, callback))
|
||||
AsyncHTTPClient().fetch(
|
||||
url, partial(_pkg_done, name, strip_release, callback))
|
||||
|
||||
def _pkg_done(name, callback, res):
|
||||
def _pkg_done(name, strip_release, callback, res):
|
||||
if res.error:
|
||||
raise res.error
|
||||
|
||||
|
@ -22,4 +24,6 @@ def _pkg_done(name, callback, res):
|
|||
return
|
||||
|
||||
version = [r['pkgver'] for r in data['results'] if r['repo'] != 'testing'][0]
|
||||
if strip_release and '-' in version:
|
||||
version = version.rsplit('-', 1)[0]
|
||||
callback(name, version)
|
||||
|
|
|
@ -11,10 +11,12 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
def get_version(name, conf, callback):
|
||||
aurname = conf.get('aur') or name
|
||||
strip_release = conf.getboolean('strip-release', False)
|
||||
url = AUR_URL + url_escape(aurname)
|
||||
AsyncHTTPClient().fetch(url, partial(_aur_done, name, callback))
|
||||
AsyncHTTPClient().fetch(
|
||||
url, partial(_aur_done, name, strip_release, callback))
|
||||
|
||||
def _aur_done(name, callback, res):
|
||||
def _aur_done(name, strip_release, callback, res):
|
||||
if res.error:
|
||||
raise res.error
|
||||
|
||||
|
@ -26,4 +28,6 @@ def _aur_done(name, callback, res):
|
|||
return
|
||||
|
||||
version = data['results']['Version']
|
||||
if strip_release and '-' in version:
|
||||
version = version.rsplit('-', 1)[0]
|
||||
callback(name, version)
|
||||
|
|
|
@ -4,4 +4,11 @@ def get_version(name, conf, callback):
|
|||
referree = conf['pacman']
|
||||
c = "LANG=C pacman -Si %s | grep -F Version | awk '{print $3}'" % referree
|
||||
conf['cmd'] = c
|
||||
cmd.get_version(name, conf, callback)
|
||||
|
||||
def callback_wrapper(name, version):
|
||||
strip_release = conf.getboolean('strip-release', False)
|
||||
if strip_release and '-' in version:
|
||||
version = version.rsplit('-', 1)[0]
|
||||
callback(name, version)
|
||||
|
||||
cmd.get_version(name, conf, callback_wrapper)
|
||||
|
|
Loading…
Add table
Reference in a new issue