From 10afe5b8dda70eaec7187ada063f551122762479 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Tue, 27 Jan 2004 19:24:39 +0000 Subject: [PATCH] Removed bestuptime. --- ChangeLog | 3 +++ plugins/Status.py | 60 --------------------------------------------- test/test_Status.py | 6 ----- 3 files changed, 3 insertions(+), 66 deletions(-) diff --git a/ChangeLog b/ChangeLog index b8ec08fef..98f96db0a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ + * Removed Status.bestuptime, since it was buggy and no one felt + like maintaining it. + * Added Http.cyborg, a fun little command for getting cyborg abbreviations for names. diff --git a/plugins/Status.py b/plugins/Status.py index 6f860404b..3a757976e 100644 --- a/plugins/Status.py +++ b/plugins/Status.py @@ -59,48 +59,6 @@ def configure(onStart, afterConnect, advanced): from questions import expect, anything, something, yn onStart.append('load Status') -class UptimeDB(object): - def __init__(self, filename='uptimes'): - dataDir = conf.supybot.directories.data() - self.filename = os.path.join(dataDir, filename) - if os.path.exists(self.filename): - fd = file(self.filename) - s = fd.read() - fd.close() - s = s.replace('\n', ' ') - self.uptimes = eval(s) - else: - self.uptimes = [] - - def die(self): - fd = file(self.filename, 'w') - fd.write(repr(self.top(50))) - fd.write('\n') - fd.close() - - def add(self): - if world.startedAt != 0 and \ - not any(lambda t: t[0] == world.startedAt, self.uptimes): - self.uptimes.append((world.startedAt, None)) - - def top(self, n=3): - def decorator(t): - return t[1] - t[0] - def invertCmp(cmp): - def f(x, y): - return -cmp(x, y) - return f - def notNone(t): - return t[1] is not None and t[0] != 0 - utils.sortBy(decorator, self.uptimes, cmp=invertCmp(cmp)) - return list(islice(ifilter(notNone, self.uptimes), n)) - - def update(self): - for (i, t) in enumerate(self.uptimes): - if t[0] == world.startedAt: - self.uptimes[i] = (t[0], time.time()) - - class Status(callbacks.Privmsg): def __init__(self): callbacks.Privmsg.__init__(self) @@ -127,24 +85,6 @@ class Status(callbacks.Privmsg): self.uptimes.update() self.uptimes.die() - def bestuptime(self, irc, msg, args): - """takes no arguments - - Returns the highest uptimes attained by the bot. - """ - L = self.uptimes.top() - if not L: - irc.error('I don\'t have enough data to answer that.') - return - def format((started, ended)): - return '%s until %s; up for %s' % \ - (time.strftime(conf.supybot.humanTimestampFormat(), - time.localtime(started)), - time.strftime(conf.supybot.humanTimestampFormat(), - time.localtime(ended)), - utils.timeElapsed(ended-started)) - irc.reply(utils.commaAndify(imap(format, L))) - def net(self, irc, msg, args): """takes no arguments diff --git a/test/test_Status.py b/test/test_Status.py index a28d30fa3..111549fcd 100644 --- a/test/test_Status.py +++ b/test/test_Status.py @@ -37,12 +37,6 @@ import world class StatusTestCase(PluginTestCase, PluginDocumentation): plugins = ('Status',) - def testBestuptime(self): - self.assertNotRegexp('bestuptime', '33 years') - self.assertNotError('unload Status') - self.assertNotError('load Status') - self.assertNotError('bestuptime') - def testNetstats(self): self.assertNotError('net')