Removed --exact.

This commit is contained in:
Jeremy Fincher 2003-12-12 13:25:03 +00:00
parent c922957655
commit 06c85f5c93
2 changed files with 5 additions and 12 deletions

View File

@ -361,15 +361,13 @@ class Factoids(plugins.ChannelDBHandler, callbacks.Privmsg):
_sqlTrans = string.maketrans('*?', '%_') _sqlTrans = string.maketrans('*?', '%_')
def search(self, irc, msg, args): def search(self, irc, msg, args):
"""[<channel>] [--{regexp,exact}=<value>] [<glob>] """[<channel>] [--{regexp}=<value>] [<glob>]
Searches the keyspace for keys matching <glob>. If --regexp is given, Searches the keyspace for keys matching <glob>. If --regexp is given,
it associated value is taken as a regexp and matched against the keys; it associated value is taken as a regexp and matched against the keys.
if --exact is given, its associated value is taken as an exact string
to match against the key.
""" """
channel = privmsgs.getChannel(msg, args) channel = privmsgs.getChannel(msg, args)
(optlist, rest) = getopt.getopt(args, '', ['regexp=', 'exact=']) (optlist, rest) = getopt.getopt(args, '', ['regexp='])
if not optlist and not rest: if not optlist and not rest:
raise callbacks.ArgumentError raise callbacks.ArgumentError
criteria = [] criteria = []
@ -377,11 +375,7 @@ class Factoids(plugins.ChannelDBHandler, callbacks.Privmsg):
predicateName = 'p' predicateName = 'p'
db = self.getDb(channel) db = self.getDb(channel)
for (option, arg) in optlist: for (option, arg) in optlist:
if option == '--exact': if option == '--regexp':
### FIXME: no way to escape LIKE metacharacters in SQLite.
criteria.append('key LIKE %s')
formats.append('%' + arg + '%')
elif option == '--regexp':
criteria.append('%s(key)' % predicateName) criteria.append('%s(key)' % predicateName)
try: try:
r = utils.perlReToPythonRe(arg) r = utils.perlReToPythonRe(arg)
@ -415,4 +409,5 @@ class Factoids(plugins.ChannelDBHandler, callbacks.Privmsg):
Class = Factoids Class = Factoids
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:

View File

@ -98,8 +98,6 @@ if sqlite is not None:
self.assertRegexp('search --regexp /^j/', self.assertRegexp('search --regexp /^j/',
'jemfinch.*jamessan') 'jemfinch.*jamessan')
self.assertRegexp('search j*', 'jemfinch.*jamessan') self.assertRegexp('search j*', 'jemfinch.*jamessan')
self.assertRegexp('search --exact ke',
'inkedmn.*strike|strike.*inkedmn')
self.assertRegexp('search *ke*', self.assertRegexp('search *ke*',
'inkedmn.*strike|strike.*inkedmn') 'inkedmn.*strike|strike.*inkedmn')
self.assertRegexp('search ke', self.assertRegexp('search ke',