mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-30 22:24:20 +01:00
Made sure to close file descriptors in debfile.
This commit is contained in:
parent
d43b1ea700
commit
28b0fdba97
@ -118,22 +118,26 @@ class Debian(callbacks.Privmsg, PeriodicFileDownloader):
|
|||||||
if self.usePythonZegrep:
|
if self.usePythonZegrep:
|
||||||
fd = gzip.open(self.contents)
|
fd = gzip.open(self.contents)
|
||||||
fd = ifilter(imap(lambda line: r.search(line), fd))
|
fd = ifilter(imap(lambda line: r.search(line), fd))
|
||||||
(fd, _) = popen2.popen4(['zegrep', regexp, self.contents])
|
(r, w) = popen2.popen4(['zegrep', regexp, self.contents])
|
||||||
packages = []
|
packages = []
|
||||||
for line in fd:
|
try:
|
||||||
try:
|
for line in fd:
|
||||||
(filename, package) = line[:-1].split()
|
try:
|
||||||
if filename == 'FILE':
|
(filename, package) = line[:-1].split()
|
||||||
# This is the last line before the actual files.
|
if filename == 'FILE':
|
||||||
continue
|
# This is the last line before the actual files.
|
||||||
except ValueError: # Unpack list of wrong size.
|
continue
|
||||||
continue # We've not gotten to the files yet.
|
except ValueError: # Unpack list of wrong size.
|
||||||
if r.search(filename):
|
continue # We've not gotten to the files yet.
|
||||||
packages.extend(package.split(','))
|
if r.search(filename):
|
||||||
if len(packages) > 40:
|
packages.extend(package.split(','))
|
||||||
irc.error(msg, 'More than 40 results returned, ' \
|
if len(packages) > 40:
|
||||||
'please be more specific.')
|
irc.error(msg, 'More than 40 results returned, ' \
|
||||||
return
|
'please be more specific.')
|
||||||
|
return
|
||||||
|
finally:
|
||||||
|
r.close()
|
||||||
|
w.close()
|
||||||
if len(packages) == 0:
|
if len(packages) == 0:
|
||||||
irc.reply(msg, 'I found no packages with that file.')
|
irc.reply(msg, 'I found no packages with that file.')
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user