mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 11:09:23 +01:00
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:
parent
4cb49606c5
commit
86b41dd4a6
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user