Allowed escaping of colons in supyfact files. Didn't allow escaping of backslashes, yet, but that's less a worry, I think.

This commit is contained in:
Jeremy Fincher 2003-11-25 09:08:06 +00:00
parent 4cb49606c5
commit 86b41dd4a6
2 changed files with 6 additions and 1 deletions

View File

@ -38,6 +38,7 @@ __revision__ = "$Id$"
import plugins
import os
import re
import sys
import sqlite
@ -110,6 +111,7 @@ class Lookup(callbacks.Privmsg):
except sqlite.DatabaseError:
irc.error(msg, 'No such lookup exists.')
_splitRe = re.compile(r'(?<!\\):')
def add(self, irc, msg, args):
"""<name> <filename>
@ -145,7 +147,8 @@ class Lookup(callbacks.Privmsg):
if not line or line.startswith('#'):
continue
try:
(key, value) = line.split(':', 1)
(key, value) = self._splitRe.split(line, 1)
key = key.replace('\\:', ':')
except ValueError:
irc.error(msg, 'Invalid line in %s: %r' % (filename, line))
return

View File

@ -47,6 +47,7 @@ if sqlite:
'foo': 'bar',
'bar': 'baz',
'your mom': 'my mom',
'foo\\:bar': 'baz',
}
def setUp(self):
PluginTestCase.setUp(self)
@ -62,6 +63,7 @@ if sqlite:
self.assertResponse('test bar', 'baz')
self.assertResponse('test your mom', 'my mom')
self.assertError('test something not in there')
self.assertResponse('test foo:bar', 'baz')
self.assertNotError('lookup remove test')
try:
original = conf.replyWhenNotCommand