mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-30 22:24:20 +01:00
Stylistic changes.
This commit is contained in:
parent
88b3d63026
commit
ac78a1c2cb
@ -58,19 +58,23 @@ dbFilename = os.path.join(conf.dataDir, 'FunDB.db')
|
|||||||
tableCreateStatements = {
|
tableCreateStatements = {
|
||||||
'larts': ("""CREATE TABLE larts (
|
'larts': ("""CREATE TABLE larts (
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY,
|
||||||
lart TEXT, added_by TEXT
|
lart TEXT,
|
||||||
|
added_by TEXT
|
||||||
)""",),
|
)""",),
|
||||||
'praises': ("""CREATE TABLE praises (
|
'praises': ("""CREATE TABLE praises (
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY,
|
||||||
praise TEXT, added_by TEXT
|
praise TEXT,
|
||||||
|
added_by TEXT
|
||||||
)""",),
|
)""",),
|
||||||
'insults': ("""CREATE TABLE insults (
|
'insults': ("""CREATE TABLE insults (
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY,
|
||||||
insult TEXT, added_by TEXT
|
insult TEXT,
|
||||||
|
added_by TEXT
|
||||||
)""",),
|
)""",),
|
||||||
'excuses': ("""CREATE TABLE excuses (
|
'excuses': ("""CREATE TABLE excuses (
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY,
|
||||||
excuse TEXT, added_by TEXT
|
excuse TEXT,
|
||||||
|
added_by TEXT
|
||||||
)""",),
|
)""",),
|
||||||
'words': ("""CREATE TABLE words (
|
'words': ("""CREATE TABLE words (
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY,
|
||||||
@ -254,11 +258,11 @@ class FunDB(callbacks.Privmsg):
|
|||||||
return
|
return
|
||||||
if table == "lart" or table == "praise":
|
if table == "lart" or table == "praise":
|
||||||
if '$who' not in s:
|
if '$who' not in s:
|
||||||
irc.error(msg, 'There must be an $who in the lart/praise '\
|
irc.error(msg, 'There must be a $who in the lart/praise '\
|
||||||
'somewhere.')
|
'somewhere.')
|
||||||
return
|
return
|
||||||
elif table not in self._tables:
|
elif table not in self._tables:
|
||||||
irc.error(msg, '"%s" is not valid. Valid values include %s' % \
|
irc.error(msg, '"%s" is not valid. Valid values include %s.' % \
|
||||||
(table, utils.commaAndify(self._tables)))
|
(table, utils.commaAndify(self._tables)))
|
||||||
return
|
return
|
||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
@ -290,7 +294,7 @@ class FunDB(callbacks.Privmsg):
|
|||||||
irc.error(msg, 'The <id> argument must be an integer.')
|
irc.error(msg, 'The <id> argument must be an integer.')
|
||||||
return
|
return
|
||||||
if table not in self._tables:
|
if table not in self._tables:
|
||||||
irc.error(msg, '"%s" is not valid. Valid values include %s' % \
|
irc.error(msg, '"%s" is not valid. Valid values include %s.' % \
|
||||||
(table, utils.commaAndify(self._tables)))
|
(table, utils.commaAndify(self._tables)))
|
||||||
return
|
return
|
||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
@ -320,13 +324,13 @@ class FunDB(callbacks.Privmsg):
|
|||||||
irc.error(msg, 'The <id> argument must be an integer.')
|
irc.error(msg, 'The <id> argument must be an integer.')
|
||||||
return
|
return
|
||||||
if table not in self._tables:
|
if table not in self._tables:
|
||||||
irc.error(msg, '"%s" is not valid. Valid values include %s' % \
|
irc.error(msg, '"%s" is not valid. Valid values include %s.' % \
|
||||||
(table, utils.commaAndify(self._tables)))
|
(table, utils.commaAndify(self._tables)))
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
replacer = utils.perlReToReplacer(regexp)
|
replacer = utils.perlReToReplacer(regexp)
|
||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
irc.error(msg, 'The regexp wasn\'t valid: %s' % e.args[0])
|
irc.error(msg, 'The regexp wasn\'t valid: %s.' % e.args[0])
|
||||||
except re.error, e:
|
except re.error, e:
|
||||||
irc.error(msg, debug.exnToString(e))
|
irc.error(msg, debug.exnToString(e))
|
||||||
return
|
return
|
||||||
@ -338,7 +342,8 @@ class FunDB(callbacks.Privmsg):
|
|||||||
else:
|
else:
|
||||||
old_entry = cursor.fetchone()[0]
|
old_entry = cursor.fetchone()[0]
|
||||||
new_entry = replacer(old_entry)
|
new_entry = replacer(old_entry)
|
||||||
sql = """UPDATE %ss SET %s=%%s, added_by=%%s WHERE id=%%s""" % (table, table)
|
sql = """UPDATE %ss SET %s=%%s, added_by=%%s WHERE id=%%s""" % \
|
||||||
|
(table, table)
|
||||||
cursor.execute(sql, new_entry, name, id)
|
cursor.execute(sql, new_entry, name, id)
|
||||||
self.db.commit()
|
self.db.commit()
|
||||||
irc.reply(msg, conf.replySuccess)
|
irc.reply(msg, conf.replySuccess)
|
||||||
@ -352,17 +357,14 @@ class FunDB(callbacks.Privmsg):
|
|||||||
table = privmsgs.getArgs(args)
|
table = privmsgs.getArgs(args)
|
||||||
table = table.lower()
|
table = table.lower()
|
||||||
if table not in self._tables:
|
if table not in self._tables:
|
||||||
irc.error(msg, '"%s" is not valid. Valid values include %s' % \
|
irc.error(msg, '%r is not valid. Valid values include %s.' % \
|
||||||
(table, utils.commaAndify(self._tables)))
|
(table, utils.commaAndify(self._tables)))
|
||||||
return
|
return
|
||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
sql = """SELECT count(*) FROM %ss""" % table
|
sql = """SELECT count(*) FROM %ss""" % table
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
try:
|
total = int(cursor.fetchone()[0])
|
||||||
total = int(cursor.fetchone()[0])
|
irc.reply(msg, 'There %s currently %s in my database.' % \
|
||||||
except ValueError:
|
|
||||||
irc.error(msg, 'Unexpected response from database')
|
|
||||||
irc.reply(msg, 'There %s currently %s in my database' % \
|
|
||||||
(utils.be(total), utils.nItems(total, table)))
|
(utils.be(total), utils.nItems(total, table)))
|
||||||
|
|
||||||
def dbget(self, irc, msg, args):
|
def dbget(self, irc, msg, args):
|
||||||
@ -378,7 +380,7 @@ class FunDB(callbacks.Privmsg):
|
|||||||
irc.error(msg, 'The <id> argument must be an integer.')
|
irc.error(msg, 'The <id> argument must be an integer.')
|
||||||
return
|
return
|
||||||
if table not in self._tables:
|
if table not in self._tables:
|
||||||
irc.error(msg, '"%s" is not valid. Valid values include %s' % \
|
irc.error(msg, '"%s" is not valid. Valid values include %s.' % \
|
||||||
(table, utils.commaAndify(self._tables)))
|
(table, utils.commaAndify(self._tables)))
|
||||||
return
|
return
|
||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
@ -403,7 +405,7 @@ class FunDB(callbacks.Privmsg):
|
|||||||
irc.error(msg, 'The <id> argument must be an integer.')
|
irc.error(msg, 'The <id> argument must be an integer.')
|
||||||
return
|
return
|
||||||
if table not in self._tables:
|
if table not in self._tables:
|
||||||
irc.error(msg, '"%s" is not valid. Valid values include %s' % \
|
irc.error(msg, '"%s" is not valid. Valid values include %s.' % \
|
||||||
(table, utils.commaAndify(self._tables)))
|
(table, utils.commaAndify(self._tables)))
|
||||||
return
|
return
|
||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
@ -488,7 +490,7 @@ class FunDB(callbacks.Privmsg):
|
|||||||
"""
|
"""
|
||||||
word = privmsgs.getArgs(args)
|
word = privmsgs.getArgs(args)
|
||||||
if word.translate(string.ascii, string.ascii_letters) != '':
|
if word.translate(string.ascii, string.ascii_letters) != '':
|
||||||
irc.error(msg, 'Word must contain only letters')
|
irc.error(msg, 'Word must contain only letters.')
|
||||||
addWord(self.db, word, commit=True)
|
addWord(self.db, word, commit=True)
|
||||||
irc.reply(msg, conf.replySuccess)
|
irc.reply(msg, conf.replySuccess)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user