mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Began some swithover to the new method; mostly I just needed to try a commit.
This commit is contained in:
parent
0743b3eb0a
commit
17478daca2
@ -38,7 +38,6 @@ from baseplugin import *
|
|||||||
import string
|
import string
|
||||||
import getopt
|
import getopt
|
||||||
import os.path
|
import os.path
|
||||||
import operator
|
|
||||||
|
|
||||||
import sqlite
|
import sqlite
|
||||||
|
|
||||||
@ -47,11 +46,12 @@ import utils
|
|||||||
import privmsgs
|
import privmsgs
|
||||||
import callbacks
|
import callbacks
|
||||||
|
|
||||||
indexFile = '/usr/ports/INDEX'
|
indexFile = 'INDEX'
|
||||||
dbFile = os.path.join(conf.dataDir, 'FreeBSD.db')
|
dbFile = os.path.join(conf.dataDir, 'FreeBSD.db')
|
||||||
|
|
||||||
def getIndex():
|
def getIndex():
|
||||||
"""Returns a file-like object that is the Ports index."""
|
"""Returns a file-like object that is the Ports index."""
|
||||||
|
# ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-stable/INDEX
|
||||||
return file(indexFile, 'r')
|
return file(indexFile, 'r')
|
||||||
|
|
||||||
def makeDb(dbfilename, indexfd, replace=False):
|
def makeDb(dbfilename, indexfd, replace=False):
|
||||||
@ -140,6 +140,7 @@ class FreeBSD(callbacks.Privmsg):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
callbacks.Privmsg.__init__(self)
|
callbacks.Privmsg.__init__(self)
|
||||||
self.db = makeDb(dbFile, getIndex())
|
self.db = makeDb(dbFile, getIndex())
|
||||||
|
self.lastUpdated = time.time()
|
||||||
|
|
||||||
_globtrans = string.maketrans('?*', '_%')
|
_globtrans = string.maketrans('?*', '_%')
|
||||||
def searchports(self, irc, msg, args):
|
def searchports(self, irc, msg, args):
|
||||||
@ -199,7 +200,9 @@ class FreeBSD(callbacks.Privmsg):
|
|||||||
irc.reply(msg, 'No ports matched those constraints.')
|
irc.reply(msg, 'No ports matched those constraints.')
|
||||||
return
|
return
|
||||||
names = [t[0] for t in cursor.fetchall()]
|
names = [t[0] for t in cursor.fetchall()]
|
||||||
if reduce(operator.add, map((2).__add__, map(len, names))) > 450:
|
shrunkenNames = names[:]
|
||||||
|
ircutils.shrinkList(shrunkenNames)
|
||||||
|
if len(names) != len(shrunkenNames):
|
||||||
irc.reply(msg, '%s ports matched those constraints. ' \
|
irc.reply(msg, '%s ports matched those constraints. ' \
|
||||||
'Please narrow your search.' % cursor.rowcount)
|
'Please narrow your search.' % cursor.rowcount)
|
||||||
else:
|
else:
|
||||||
@ -256,4 +259,5 @@ Class = FreeBSD
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
makeDb(dbFile, getIndex(), replace=True)
|
makeDb(dbFile, getIndex(), replace=True)
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
Loading…
Reference in New Issue
Block a user