Handled empty lines appropriately in supyfact files.

This commit is contained in:
Jeremy Fincher 2003-11-19 22:39:01 +00:00
parent c17f85e51b
commit e20f69288c
2 changed files with 8 additions and 2 deletions

View File

@ -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:

View File

@ -73,6 +73,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')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: