From 46a407698884be6c42cee8eeb1c3d0d36f1e8d14 Mon Sep 17 00:00:00 2001 From: James Vega Date: Fri, 27 Feb 2009 14:17:05 -0500 Subject: [PATCH] Add .gitignore Signed-off-by: James Vega --- .gitignore | 4 ++++ plugins/Factoids/plugin.py | 6 ++++-- plugins/Karma/plugin.py | 2 +- plugins/QuoteGrabs/plugin.py | 36 ++++++++++++++++-------------------- plugins/QuoteGrabs/test.py | 25 +++++++++++++------------ scripts/supybot | 2 +- setup.py | 2 +- src/conf.py | 2 +- src/questions.py | 11 ++++++----- 9 files changed, 47 insertions(+), 43 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..481c02ba7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +build +test-data +test-conf +test-logs diff --git a/plugins/Factoids/plugin.py b/plugins/Factoids/plugin.py index 412e73e77..17f6a34f6 100644 --- a/plugins/Factoids/plugin.py +++ b/plugins/Factoids/plugin.py @@ -110,7 +110,7 @@ class Factoids(callbacks.Plugin, plugins.ChannelDBHandler): return help(method, doc=method._fake__doc__ % (s, s), name=callbacks.formatCommand(command)) - return self.__parent.getCommandHelp(command) + return super(Factoids, self).getCommandHelp(self, command) def learn(self, irc, msg, args, channel, key, factoid): db = self.getDb(channel) @@ -328,7 +328,9 @@ class Factoids(callbacks.Plugin, plugins.ChannelDBHandler): counter = 0 for (added_by, added_at) in factoids: counter += 1 - L.append(format('#%i was added by %s at %t', + added_at = time.strftime(conf.supybot.reply.format.time(), + time.localtime(int(added_at))) + L.append(format('#%i was added by %s at %s', counter, added_by, added_at)) factoids = '; '.join(L) s = format('Key %q is %s and has %n associated with it: %s', diff --git a/plugins/Karma/plugin.py b/plugins/Karma/plugin.py index 1a78bdeb4..cc298a62f 100644 --- a/plugins/Karma/plugin.py +++ b/plugins/Karma/plugin.py @@ -90,7 +90,7 @@ class SqliteKarmaDB(object): def gets(self, channel, things): db = self._getDb(channel) cursor = db.cursor() - normalizedThings = dict(zip(map(str.lower, things), things)) + normalizedThings = dict(zip(map(lambda s: s.lower(), things), things)) criteria = ' OR '.join(['normalized=%s'] * len(normalizedThings)) sql = """SELECT name, added-subtracted FROM karma WHERE %s ORDER BY added-subtracted DESC""" % criteria diff --git a/plugins/QuoteGrabs/plugin.py b/plugins/QuoteGrabs/plugin.py index a8691a6e3..dfd49911e 100644 --- a/plugins/QuoteGrabs/plugin.py +++ b/plugins/QuoteGrabs/plugin.py @@ -1,5 +1,6 @@ ### # Copyright (c) 2004, Daniel DiPaolo +# Copyright (c) 2008, James Vega # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -50,11 +51,9 @@ class QuoteGrabsRecord(dbi.Record): ] def __str__(self): - at = time.strftime(conf.supybot.reply.format.time(), - time.localtime(float(self.at))) grabber = plugins.getUserName(self.grabber) - return '%s (Said by: %s; grabbed by %s at %s)' % \ - (self.text, self.hostmask, grabber, at) + return format('%s (Said by: %s; grabbed by %s at %t)', + self.text, self.hostmask, grabber, self.at) class SqliteQuoteGrabsDB(object): def __init__(self, filename): @@ -152,8 +151,7 @@ class SqliteQuoteGrabsDB(object): raise dbi.NoRecordError return cursor.fetchone()[0] - def add(self, msg, by): - channel = msg.args[0] + def add(self, channel, msg, by): db = self._getDb(channel) cursor = db.cursor() text = ircmsgs.prettyPrint(msg) @@ -193,29 +191,27 @@ class QuoteGrabs(callbacks.Plugin): def doPrivmsg(self, irc, msg): irc = callbacks.SimpleProxy(irc, msg) if irc.isChannel(msg.args[0]): - (channel, payload) = msg.args - words = self.registryValue('randomGrabber.minimumWords', - channel) - length = self.registryValue('randomGrabber.minimumCharacters', - channel) + (chan, payload) = msg.args + words = self.registryValue('randomGrabber.minimumWords', chan) + length = self.registryValue('randomGrabber.minimumCharacters',chan) grabTime = \ - self.registryValue('randomGrabber.averageTimeBetweenGrabs', - channel) - if self.registryValue('randomGrabber', channel): + self.registryValue('randomGrabber.averageTimeBetweenGrabs', chan) + channel = plugins.getChannel(chan) + if self.registryValue('randomGrabber', chan): if len(payload) > length and len(payload.split()) > words: try: last = int(self.db.select(channel, msg.nick)) except dbi.NoRecordError: - self._grab(irc, msg, irc.prefix) + self._grab(irc, channel, msg, irc.prefix) self._sendGrabMsg(irc, msg) else: elapsed = int(time.time()) - last - if random.random()*elapsed > grabTime/2: - self._grab(irc, msg, irc.prefix) + if (random.random() * elapsed) > (grabTime / 2): + self._grab(channel, irc, msg, irc.prefix) self._sendGrabMsg(irc, msg) - def _grab(self, irc, msg, addedBy): - self.db.add(msg, addedBy) + def _grab(self, channel, irc, msg, addedBy): + self.db.add(channel, msg, addedBy) def _sendGrabMsg(self, irc, msg): s = 'jots down a new quote for %s' % msg.nick @@ -239,7 +235,7 @@ class QuoteGrabs(callbacks.Plugin): for m in reversed(irc.state.history): if m.command == 'PRIVMSG' and ircutils.nickEqual(m.nick, nick) \ and ircutils.strEqual(m.args[0], chan): - self._grab(irc, m, msg.prefix) + self._grab(channel, irc, m, msg.prefix) irc.replySuccess() return irc.error('I couldn\'t find a proper message to grab.') diff --git a/plugins/QuoteGrabs/test.py b/plugins/QuoteGrabs/test.py index b12985592..d26eed18d 100644 --- a/plugins/QuoteGrabs/test.py +++ b/plugins/QuoteGrabs/test.py @@ -1,5 +1,6 @@ ### # Copyright (c) 2004, Daniel DiPaolo +# Copyright (c) 2008, James Vega # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -52,28 +53,28 @@ class QuoteGrabsTestCase(ChannelPluginTestCase): def testList(self): testPrefix = 'foo!bar@baz' - self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'test', + self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'testList', prefix=testPrefix)) self.assertNotError('grab foo') - self.assertResponse('quotegrabs list foo', '#1: test') + self.assertResponse('quotegrabs list foo', '#1: testList') self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'a' * 80, prefix=testPrefix)) self.assertNotError('grab foo') self.assertResponse('quotegrabs list foo', - '#2: %s... and #1: test' %\ + '#2: %s... and #1: testList' %\ ('a'*43)) # 50 - length of "#2: ..." def testDuplicateGrabs(self): testPrefix = 'foo!bar@baz' - self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'test', + self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'testDupe', prefix=testPrefix)) self.assertNotError('grab foo') self.assertNotError('grab foo') # note:NOTanerror,stillwon'tdupe - self.assertResponse('quotegrabs list foo', '#1: test') + self.assertResponse('quotegrabs list foo', '#1: testDupe') def testCaseInsensitivity(self): testPrefix = 'foo!bar@baz' - self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'test', + self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'testCI', prefix=testPrefix)) self.assertNotError('grab FOO') self.assertNotError('quote foo') @@ -85,26 +86,26 @@ class QuoteGrabsTestCase(ChannelPluginTestCase): def testRandom(self): testPrefix = 'foo!bar@baz' self.assertError('random') - self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'test', + self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'testRandom', prefix=testPrefix)) self.assertError('random') # still none in the db self.assertNotError('grab foo') - self.assertResponse('random', ' test') - self.assertResponse('random foo', ' test') - self.assertResponse('random FOO', ' test') + self.assertResponse('random', ' testRandom') + self.assertResponse('random foo', ' testRandom') + self.assertResponse('random FOO', ' testRandom') def testGet(self): testPrefix= 'foo!bar@baz' self.assertError('quotegrabs get asdf') self.assertError('quotegrabs get 1') - self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'test', + self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'testGet', prefix=testPrefix)) self.assertNotError('grab foo') self.assertNotError('quotegrabs get 1') def testSearch(self): testPrefix= 'foo!bar@baz' - self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'test', + self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'testSearch', prefix=testPrefix)) self.assertError('quotegrabs search test') # still none in db self.assertNotError('grab foo') diff --git a/scripts/supybot b/scripts/supybot index 972b5f212..5ddd3668a 100644 --- a/scripts/supybot +++ b/scripts/supybot @@ -123,7 +123,7 @@ def main(): log.info('Total CPU time taken: %s seconds.', user+system) log.info('No more Irc objects, exiting.') -version = '0.83.3+svn' +version = '0.83.3' if __name__ == '__main__': ### # Options: diff --git a/setup.py b/setup.py index d059774aa..a63cf184f 100644 --- a/setup.py +++ b/setup.py @@ -151,7 +151,7 @@ package_dir = {'supybot': 'src', for plugin in plugins: package_dir['supybot.plugins.' + plugin] = 'plugins/' + plugin -version = '0.83.3+svn' +version = '0.83.3' setup( # Metadata name='supybot', diff --git a/src/conf.py b/src/conf.py index 365849161..e45d15fbb 100644 --- a/src/conf.py +++ b/src/conf.py @@ -43,7 +43,7 @@ _pluginsDir = os.path.join(installDir, 'plugins') ### # version: This should be pretty obvious. ### -version = '0.83.3+svn' +version = '0.83.3' ### # *** The following variables are affected by command-line options. They are diff --git a/src/questions.py b/src/questions.py index 2c4c62162..34ebfcd93 100644 --- a/src/questions.py +++ b/src/questions.py @@ -65,15 +65,17 @@ def expect(prompt, possibilities, recursed=False, default=None, if len(prompt) > 70: prompt = '%s %s' % (originalPrompt, choices % '/ '.join(possibilities)) if default is not None: - prompt = '%s (default: %s)' % (prompt, default) + if useBold: + prompt = '%s %s(default: %s)' % (prompt, ansi.RESET, default) + else: + prompt = '%s (default: %s)' % (prompt, default) prompt = textwrap.fill(prompt) prompt = prompt.replace('/ ', '/') prompt = prompt.strip() + ' ' if useBold: + prompt += ansi.RESET print >>fd, ansi.BOLD, s = raw_input(prompt) - if useBold: - print >>fd, ansi.RESET s = s.strip() print >>fd if possibilities: @@ -125,11 +127,10 @@ def getpass(prompt='Enter password: ', secondPrompt='Re-enter password: '): prompt += ' ' while True: if useBold: + prompt += ansi.RESET sys.stdout.write(ansi.BOLD) password = getPass(prompt) secondPassword = getPass(secondPrompt) - if useBold: - print ansi.RESET if password != secondPassword: output('Passwords don\'t match.') else: