Fixed the order of arguments on debversion and made it only do one package at a time.

This commit is contained in:
Jeremy Fincher 2003-10-16 14:03:12 +00:00
parent 1e00aab6d2
commit a6ddd4816c

View File

@ -40,6 +40,7 @@ import gzip
import sets
import getopt
import popen2
#import urllib
import fnmatch
import os.path
import urllib2
@ -182,25 +183,24 @@ class Debian(callbacks.Privmsg, plugins.PeriodicFileDownloader):
_debnumpkgsre = re.compile(r'out of total of (\d+)', _debreflags)
_debBranches = ('stable', 'testing', 'unstable', 'experimental')
def debversion(self, irc, msg, args):
"""<package name> [stable|testing|unstable|experimental]
"""[stable|testing|unstable|experimental] <package name>
Returns the current version(s) of a Debian package in the given branch
(if any, otherwise all available ones are displayed).
"""
if args and args[-1] in self._debBranches:
branch = args.pop()
if args and args[0] in self._debBranches:
branch = args.pop(0)
else:
branch = 'all'
if not args:
irc.error(msg, 'You must give a package name.')
responses = []
numberOfPackages = 0
for package in args:
fd = urllib2.urlopen('http://packages.debian.org/cgi-bin/' \
'search_packages.pl?' \
'keywords=%s&searchon=names&' \
'version=%s&release=all' % \
(package, branch))
package = privmsgs.getArgs(args)
package = urllib.quote(package)
url = 'http://packages.debian.org/cgi-bin/search_packages.pl?keywords'\
'=%s&searchon=names&version=%s&release=all' % (package, branch)
fd = urllib2.urlopen(url)
html = fd.read()
fd.close()
m = self._debnumpkgsre.search(html)
@ -208,8 +208,8 @@ class Debian(callbacks.Privmsg, plugins.PeriodicFileDownloader):
numberOfPackages = m.group(1)
m = self._debtablere.search(html)
if m is None:
irc.reply(msg, 'No package found for: %s (%s)' % \
(package, branch))
irc.reply(msg, 'No package found for %s (%s)' % \
(urllib.unquote(package), branch))
else:
tableData = m.group(1)
rows = tableData.split('</TR>')