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 plugins
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import sqlite
|
import sqlite
|
||||||
@ -110,6 +111,7 @@ class Lookup(callbacks.Privmsg):
|
|||||||
except sqlite.DatabaseError:
|
except sqlite.DatabaseError:
|
||||||
irc.error(msg, 'No such lookup exists.')
|
irc.error(msg, 'No such lookup exists.')
|
||||||
|
|
||||||
|
_splitRe = re.compile(r'(?<!\\):')
|
||||||
def add(self, irc, msg, args):
|
def add(self, irc, msg, args):
|
||||||
"""<name> <filename>
|
"""<name> <filename>
|
||||||
|
|
||||||
@ -145,7 +147,8 @@ class Lookup(callbacks.Privmsg):
|
|||||||
if not line or line.startswith('#'):
|
if not line or line.startswith('#'):
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
(key, value) = line.split(':', 1)
|
(key, value) = self._splitRe.split(line, 1)
|
||||||
|
key = key.replace('\\:', ':')
|
||||||
except ValueError:
|
except ValueError:
|
||||||
irc.error(msg, 'Invalid line in %s: %r' % (filename, line))
|
irc.error(msg, 'Invalid line in %s: %r' % (filename, line))
|
||||||
return
|
return
|
||||||
|
@ -47,6 +47,7 @@ if sqlite:
|
|||||||
'foo': 'bar',
|
'foo': 'bar',
|
||||||
'bar': 'baz',
|
'bar': 'baz',
|
||||||
'your mom': 'my mom',
|
'your mom': 'my mom',
|
||||||
|
'foo\\:bar': 'baz',
|
||||||
}
|
}
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
PluginTestCase.setUp(self)
|
PluginTestCase.setUp(self)
|
||||||
@ -62,6 +63,7 @@ if sqlite:
|
|||||||
self.assertResponse('test bar', 'baz')
|
self.assertResponse('test bar', 'baz')
|
||||||
self.assertResponse('test your mom', 'my mom')
|
self.assertResponse('test your mom', 'my mom')
|
||||||
self.assertError('test something not in there')
|
self.assertError('test something not in there')
|
||||||
|
self.assertResponse('test foo:bar', 'baz')
|
||||||
self.assertNotError('lookup remove test')
|
self.assertNotError('lookup remove test')
|
||||||
try:
|
try:
|
||||||
original = conf.replyWhenNotCommand
|
original = conf.replyWhenNotCommand
|
||||||
|
Loading…
Reference in New Issue
Block a user