From b995b2fd5c3b3fd976b8b5468f6375c7820234bc Mon Sep 17 00:00:00 2001 From: Daniel DiPaolo Date: Thu, 18 Dec 2003 04:47:05 +0000 Subject: [PATCH] Fixed a kernel bug which only happens when either one of the stable or beta kernels isn't listed on the page and also fixed the geekquote tests to match the new behavior. --- plugins/Http.py | 18 ++++++------------ test/test_Http.py | 6 ++++-- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/plugins/Http.py b/plugins/Http.py index 4d91eb86f..1d0c105ef 100644 --- a/plugins/Http.py +++ b/plugins/Http.py @@ -329,21 +329,13 @@ class Http(callbacks.Privmsg): _mlgeekquotere = re.compile('

(.*?)

', re.M | re.DOTALL) def geekquote(self, irc, msg, args): - """[--id=] + """[] Returns a random geek quote from bash.org; the optional argument - --id specifies which quote to retrieve. + id specifies which quote to retrieve. """ - (optlist, rest) = getopt.getopt(args, '', ['id=']) - id = 'random1' - for (option, arg) in optlist: - if option == '--id': - try: - id = int(arg) - except ValueError, e: - irc.error(msg, 'Invalid id: %s' % e) - return - + id = privmsgs.getArgs(args, required=0, optional=1) + id = id or 'random1' html = webutils.getUrl('http://bash.org/?%s' % id) m = self._mlgeekquotere.search(html) if m is None: @@ -413,6 +405,8 @@ class Http(callbacks.Privmsg): except webutils.WebError, e: irc.error(msg, str(e)) return + stable = 'unknown' + beta = 'unknown' for line in fd: (name, version) = line.split(':') if 'latest stable' in name: diff --git a/test/test_Http.py b/test/test_Http.py index 703df7a27..e5813e399 100644 --- a/test/test_Http.py +++ b/test/test_Http.py @@ -84,8 +84,10 @@ class HttpTest(PluginTestCase, PluginDocumentation): def testGeekquote(self): self.assertNotError('geekquote') - self.assertNotError('geekquote --id=4848') - self.assertError('geekquote --id=48a') + self.assertNotError('geekquote 4848') + # It's not an error, it just truncates at the first non-number + #self.assertError('geekquote 48a8') + self.assertError('geekquote asdf') def testAcronym(self): self.assertRegexp('acronym ASAP', 'as soon as possible')