From a6ddd4816c5f7aaa9816922798a572bf5a40b76a Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Thu, 16 Oct 2003 14:03:12 +0000 Subject: [PATCH] Fixed the order of arguments on debversion and made it only do one package at a time. --- plugins/Debian.py | 60 +++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/plugins/Debian.py b/plugins/Debian.py index 3c184c83c..3b5352c90 100644 --- a/plugins/Debian.py +++ b/plugins/Debian.py @@ -40,6 +40,7 @@ import gzip import sets import getopt import popen2 +#import urllib import fnmatch import os.path import urllib2 @@ -182,46 +183,45 @@ 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): - """ [stable|testing|unstable|experimental] + """[stable|testing|unstable|experimental] 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)) - html = fd.read() - fd.close() - m = self._debnumpkgsre.search(html) - if m: - numberOfPackages = m.group(1) - m = self._debtablere.search(html) - if m is None: - irc.reply(msg, 'No package found for: %s (%s)' % \ - (package, branch)) - else: - tableData = m.group(1) - rows = tableData.split('') - for row in rows: - pkgMatch = self._debpkgre.search(row) - brMatch = self._debbrre.search(row) - if pkgMatch and brMatch: - s = '%s (%s)' % (pkgMatch.group(1), brMatch.group(1)) - responses.append(s) - resp = 'Total matches: %s, shown: %s. %s' % \ - (numberOfPackages, len(responses), ', '.join(responses)) - irc.reply(msg, resp) + 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) + if m: + numberOfPackages = m.group(1) + m = self._debtablere.search(html) + if m is None: + irc.reply(msg, 'No package found for %s (%s)' % \ + (urllib.unquote(package), branch)) + else: + tableData = m.group(1) + rows = tableData.split('') + for row in rows: + pkgMatch = self._debpkgre.search(row) + brMatch = self._debbrre.search(row) + if pkgMatch and brMatch: + s = '%s (%s)' % (pkgMatch.group(1), brMatch.group(1)) + responses.append(s) + resp = 'Total matches: %s, shown: %s. %s' % \ + (numberOfPackages, len(responses), ', '.join(responses)) + irc.reply(msg, resp) _incomingRe = re.compile(r'', re.I) def debincoming(self, irc, msg, args):