add PyPI support
API: https://wiki.python.org/moin/PyPIJSON?action=show&redirect=PyPiJson
This commit is contained in:
parent
110d083bb9
commit
27df5909e3
|
@ -12,7 +12,7 @@ import tornado.process
|
|||
from tornado.ioloop import IOLoop
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
handler_precedence = ('github', 'aur', 'cmd', 'regex')
|
||||
handler_precedence = ('github', 'aur', 'pypi', 'cmd', 'regex')
|
||||
|
||||
try:
|
||||
import pycurl
|
||||
|
@ -122,3 +122,16 @@ def _command_done(name, callback, process, status):
|
|||
def _got_version_from_cmd(callback, name, output):
|
||||
output = output.strip().decode('latin1')
|
||||
callback(name, output)
|
||||
|
||||
PYPI_URL = 'https://pypi.python.org/pypi/%s/json'
|
||||
|
||||
def get_version_by_pypi(name, conf, callback):
|
||||
repo = conf.get('pypi') or name
|
||||
url = PYPI_URL % repo
|
||||
AsyncHTTPClient().fetch(url, user_agent='lilydjwg/nvchecker',
|
||||
callback=partial(_pypi_done, name, callback))
|
||||
|
||||
def _pypi_done(name, callback, res):
|
||||
data = json.loads(res.body.decode('utf-8'))
|
||||
version = data['info']['version']
|
||||
callback(name, version)
|
||||
|
|
|
@ -29,3 +29,6 @@ github = lilydjwg/nvchecker
|
|||
url = http://sed.sourceforge.net/grabbag/ssed/
|
||||
regex = The current version is ([\d.]+)\.
|
||||
proxy = localhost:8087
|
||||
|
||||
[PySide]
|
||||
pypi = PySide
|
||||
|
|
Loading…
Reference in New Issue