add gcode_svn source: for Google Code svn repositories

This commit is contained in:
lilydjwg 2014-12-18 15:27:22 +08:00
parent 0bf4559c3c
commit be7e9105c0
3 changed files with 34 additions and 1 deletions

View File

@ -150,6 +150,13 @@ Check a mercurial (hg) repository on `Google Code <https://code.google.com/>`_ f
gcode_hg
The name used on Google Code, e.g. ``chromium-compact-language-detector``.
Check Google Code (svn repository)
---------------------------------
Check a subversion (svn) repository on `Google Code <https://code.google.com/>`_ for updates. The version returned is the svn resivion number.
gcode_svn
The name used on Google Code, e.g. ``cld2``.
Manually updating
-----------------
This enables you to manually specify the version (maybe because you want to approve each release before it gets to the script).

View File

@ -4,7 +4,7 @@ from importlib import import_module
logger = logging.getLogger(__name__)
handler_precedence = (
'github', 'aur', 'pypi', 'archpkg', 'gems', 'pacman',
'cmd', 'gcode_hg', 'regex', 'manual', 'vcs'
'cmd', 'gcode_hg', 'gcode_svn', 'regex', 'manual', 'vcs'
)
def get_version(name, conf, callback):

View File

@ -0,0 +1,26 @@
import re
import logging
from functools import partial
from tornado.httpclient import AsyncHTTPClient
logger = logging.getLogger(__name__)
GCODE_URL = 'https://code.google.com/p/%s/source/list'
GCODE_SVN_RE = re.compile(r'<a href="detail\?r=\d+">r(\d+)</a>')
def get_version(name, conf, callback):
repo = conf.get('gcode_svn') or name
url = GCODE_URL % repo
AsyncHTTPClient().fetch(url, user_agent='lilydjwg/nvchecker',
callback=partial(_gcodehg_done, name, callback))
def _gcodehg_done(name, callback, res):
data = res.body.decode('utf-8')
m = GCODE_SVN_RE.search(data)
if m:
version = m.group(1)
else:
logger.error('%s: version not found.', name)
version = None
callback(name, version)