Debian: fix bugs in @version and add more options
This commit is contained in:
parent
314b85777f
commit
306957533c
@ -241,24 +241,32 @@ class Debian(callbacks.Plugin, PeriodicFileDownloader):
|
|||||||
|
|
||||||
_debreflags = re.DOTALL | re.IGNORECASE
|
_debreflags = re.DOTALL | re.IGNORECASE
|
||||||
_deblistre = re.compile(r'<h3>Package ([^<]+)</h3>(.*?)</ul>', _debreflags)
|
_deblistre = re.compile(r'<h3>Package ([^<]+)</h3>(.*?)</ul>', _debreflags)
|
||||||
def version(self, irc, msg, args, optlist, branch, package):
|
def version(self, irc, msg, args, optlist, package):
|
||||||
"""[--exact] [{stable,testing,unstable,experimental}] <package name>
|
"""[--exact] \
|
||||||
|
[--branch {oldstable,stable,testing,unstable,experimental}] \
|
||||||
|
[--section {main,contrib,non-free}] <package name>
|
||||||
|
|
||||||
Returns the current version(s) of a Debian package in the given branch
|
Returns the current version(s) of a Debian package in the given branch
|
||||||
(if any, otherwise all available ones are displayed). If --exact is
|
(if any, otherwise all available ones are displayed). If --exact is
|
||||||
specified, only packages whose name exactly matches <package name>
|
specified, only packages whose name exactly matches <package name>
|
||||||
will be reported.
|
will be reported.
|
||||||
"""
|
"""
|
||||||
url = 'http://packages.debian.org/cgi-bin/search_packages.pl?keywords'\
|
url = 'http://packages.debian.org/search?keywords=%(keywords)s' + \
|
||||||
'=%s&searchon=names&version=%s&release=all&subword=1'
|
'&searchon=%(mode)s&suite=%(suite)s§ion=%(section)s'
|
||||||
for (option, _) in optlist:
|
args = {'keywords': None, 'mode': 'names', 'suite': 'all',
|
||||||
if option == 'exact':
|
'section': 'all'}
|
||||||
url = url.replace('&subword=1','')
|
for (key, value) in optlist:
|
||||||
|
if key == 'exact':
|
||||||
|
url += '&exact=1'
|
||||||
|
elif key == 'branch':
|
||||||
|
args['suite'] = value
|
||||||
|
elif key == 'section':
|
||||||
|
args['section'] = value
|
||||||
responses = []
|
responses = []
|
||||||
if '*' in package:
|
if '*' in package:
|
||||||
irc.error('Wildcard characters can not be specified.', Raise=True)
|
irc.error('Wildcard characters can not be specified.', Raise=True)
|
||||||
package = utils.web.urlquote(package)
|
args['keywords'] = utils.web.urlquote(package)
|
||||||
url %= (package, branch)
|
url %= args
|
||||||
try:
|
try:
|
||||||
html = utils.web.getUrl(url)
|
html = utils.web.getUrl(url)
|
||||||
except utils.web.Error, e:
|
except utils.web.Error, e:
|
||||||
@ -270,7 +278,7 @@ class Debian(callbacks.Plugin, PeriodicFileDownloader):
|
|||||||
pkgs = self._deblistre.findall(html)
|
pkgs = self._deblistre.findall(html)
|
||||||
if not pkgs:
|
if not pkgs:
|
||||||
irc.reply(format('No package found for %s (%s)',
|
irc.reply(format('No package found for %s (%s)',
|
||||||
utils.web.urlunquote(package), branch))
|
utils.web.urlunquote(package), args['suite']))
|
||||||
else:
|
else:
|
||||||
for pkg in pkgs:
|
for pkg in pkgs:
|
||||||
pkgMatch = pkg[0]
|
pkgMatch = pkg[0]
|
||||||
@ -295,10 +303,16 @@ class Debian(callbacks.Plugin, PeriodicFileDownloader):
|
|||||||
resp = format('%i matches found: %s',
|
resp = format('%i matches found: %s',
|
||||||
len(responses), '; '.join(responses))
|
len(responses), '; '.join(responses))
|
||||||
irc.reply(resp)
|
irc.reply(resp)
|
||||||
version = wrap(version, [getopts({'exact':''}),
|
version = wrap(version, [getopts({'exact': '',
|
||||||
optional(('literal', ('stable', 'testing',
|
'branch': ('literal', ('oldstable',
|
||||||
'unstable', 'experimental')), 'all'),
|
'stable',
|
||||||
'text'])
|
'testing',
|
||||||
|
'unstable',
|
||||||
|
'experimental')),
|
||||||
|
'arch': ('literal', ('main',
|
||||||
|
'contrib',
|
||||||
|
'non-free'))}),
|
||||||
|
'text'])
|
||||||
|
|
||||||
_incomingRe = re.compile(r'<a href="(.*?\.deb)">', re.I)
|
_incomingRe = re.compile(r'<a href="(.*?\.deb)">', re.I)
|
||||||
def incoming(self, irc, msg, args, optlist, globs):
|
def incoming(self, irc, msg, args, optlist, globs):
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
###
|
###
|
||||||
# Copyright (c) 2003-2005, James Vega
|
# Copyright (c) 2003-2005, James Vega
|
||||||
|
# Copyright (c) 2011, Valentin Lorentz
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
@ -63,15 +64,17 @@ class DebianTestCase(PluginTestCase):
|
|||||||
self.assertHelp('debian version')
|
self.assertHelp('debian version')
|
||||||
self.assertRegexp('debian version lakjdfad',
|
self.assertRegexp('debian version lakjdfad',
|
||||||
r'^No package.*\(all\)')
|
r'^No package.*\(all\)')
|
||||||
self.assertRegexp('debian version unstable alkdjfad',
|
self.assertRegexp('debian version --branch unstable alkdjfad',
|
||||||
r'^No package.*\(unstable\)')
|
r'^No package.*\(unstable\)')
|
||||||
self.assertRegexp('debian version gaim',
|
self.assertRegexp('debian version --branch stable gaim',
|
||||||
r'\d+ matches found:.*gaim.*\(stable')
|
r'\d+ matches found:.*gaim.*\(stable')
|
||||||
self.assertRegexp('debian version linux-wlan',
|
self.assertRegexp('debian version linux-wlan',
|
||||||
r'\d+ matches found:.*linux-wlan.*')
|
r'\d+ matches found:.*linux-wlan.*')
|
||||||
self.assertRegexp('debian version --exact linux-wlan',
|
self.assertRegexp('debian version --exact linux-wlan',
|
||||||
r'^No package.*\(all\)')
|
r'^No package.*\(all\)')
|
||||||
self.assertError('debian version unstable')
|
self.assertNotError('debian version unstable')
|
||||||
|
self.assertRegexp('debian version --branch stable unstable',
|
||||||
|
r'^No package.*')
|
||||||
|
|
||||||
def testDebfile(self):
|
def testDebfile(self):
|
||||||
self.assertHelp('file')
|
self.assertHelp('file')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user