Add support for Hackage

This commit is contained in:
Felix Yan 2015-11-04 18:01:47 +08:00
parent 3dce06ca21
commit 0a3d62986a
3 changed files with 25 additions and 0 deletions

View file

@ -159,6 +159,13 @@ Check `RubyGems <https://rubygems.org/>`_ for updates.
gems
The name used on RubyGems, e.g. ``sass``.
Check Hackage
----------
Check `Hackage <https://hackage.haskell.org/>`_ for updates.
hackage
The name used on Hackage, e.g. ``pandoc``.
Check Local Pacman Database
---------------------------
This is used when you run ``nvchecker`` on an Arch Linux system and the program always keeps up with a package in your configured repositories for `Pacman`_.

View file

@ -5,6 +5,7 @@ logger = logging.getLogger(__name__)
handler_precedence = (
'github', 'gitcafe', 'aur', 'pypi', 'archpkg', 'gems', 'pacman',
'cmd', 'bitbucket', 'gcode_hg', 'gcode_svn', 'regex', 'manual', 'vcs',
'hackage',
)
def get_version(name, conf, callback):

View file

@ -0,0 +1,17 @@
import json
from functools import partial
from tornado.httpclient import AsyncHTTPClient
HACKAGE_URL = 'https://hackage.haskell.org/package/%s/preferred.json'
def get_version(name, conf, callback):
repo = conf.get('hackage') or name
url = HACKAGE_URL % repo
AsyncHTTPClient().fetch(url, user_agent='lilydjwg/nvchecker',
callback=partial(_hackage_done, name, callback))
def _hackage_done(name, callback, res):
data = json.loads(res.body.decode('utf-8'))
version = data['normal-version'][0]
callback(name, version)