mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-11 12:42:34 +01:00
Handled empty lines appropriately in supyfact files.
This commit is contained in:
parent
c17f85e51b
commit
e20f69288c
@ -136,9 +136,9 @@ class Lookup(callbacks.Privmsg):
|
|||||||
cursor.execute("""CREATE TABLE %s (key TEXT, value TEXT)""" % name)
|
cursor.execute("""CREATE TABLE %s (key TEXT, value TEXT)""" % name)
|
||||||
sql = """INSERT INTO %s VALUES (%%s, %%s)""" % name
|
sql = """INSERT INTO %s VALUES (%%s, %%s)""" % name
|
||||||
for line in fd:
|
for line in fd:
|
||||||
if line.startswith('#'):
|
|
||||||
continue
|
|
||||||
line = line.rstrip('\r\n')
|
line = line.rstrip('\r\n')
|
||||||
|
if not line or line.startswith('#'):
|
||||||
|
continue
|
||||||
try:
|
try:
|
||||||
(key, value) = line.split(':', 1)
|
(key, value) = line.split(':', 1)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
@ -72,6 +72,12 @@ class LookupTestCase(PluginTestCase, PluginDocumentation):
|
|||||||
|
|
||||||
def testNotEscapingIOError(self):
|
def testNotEscapingIOError(self):
|
||||||
self.assertNotRegexp('lookup add foo asdlfkjsdalfkj', 'IOError')
|
self.assertNotRegexp('lookup add foo asdlfkjsdalfkj', 'IOError')
|
||||||
|
|
||||||
|
def testEmptyLines(self):
|
||||||
|
fd = file(os.path.join(conf.dataDir, 'foo.supyfact'), 'a')
|
||||||
|
fd.write('\n')
|
||||||
|
fd.close()
|
||||||
|
self.assertNotError('lookup add test foo.supyfact')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user