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