* Fixed Debian's debfile command to work properly

This commit is contained in:
Daniel DiPaolo 2003-09-11 18:46:17 +00:00
parent 9eb08fa205
commit 47ea9b809f

View File

@ -37,6 +37,7 @@ from baseplugin import *
import re import re
import gzip import gzip
import sets
import popen2 import popen2
import random import random
import os.path import os.path
@ -122,24 +123,23 @@ class Debian(callbacks.Privmsg, PeriodicFileDownloader):
try: try:
r = re.compile(regexp, re.I) r = re.compile(regexp, re.I)
except re.error, e: except re.error, e:
irc.error(msg, e) irc.error(msg, )
return return
if self.usePythonZegrep: if self.usePythonZegrep:
r = gzip.open(self.contents) r = gzip.open(self.contents)
r = ifilter(imap(lambda line: r.search(line), fd)) r = ifilter(imap(lambda line: r.search(line), fd))
(r, w) = popen2.popen4(['zegrep', regexp, self.contents]) (r, w) = popen2.popen4(['zegrep', regexp, self.contents])
packages = [] packages = sets.Set() # Make packages unique
try: try:
for line in r: for line in r:
try: try:
(filename, package) = line[:-1].split() (filename, pkg_list) = line[:-1].split()
if filename == 'FILE': if filename == 'FILE':
# This is the last line before the actual files. # This is the last line before the actual files.
continue continue
except ValueError: # Unpack list of wrong size. except ValueError: # Unpack list of wrong size.
continue # We've not gotten to the files yet. continue # We've not gotten to the files yet.
if r.search(filename): packages.update(pkg_list.split(','))
packages.extend(package.split(','))
if len(packages) > 40: if len(packages) > 40:
irc.error(msg, 'More than 40 results returned, ' \ irc.error(msg, 'More than 40 results returned, ' \
'please be more specific.') 'please be more specific.')