From 29a3264126fe8e09ac7befbf2ae7fbd246ad2547 Mon Sep 17 00:00:00 2001 From: James Vega Date: Sat, 18 Oct 2003 14:19:06 +0000 Subject: [PATCH] Added more information to the snarfer and cleaned up the related tests. --- plugins/Sourceforge.py | 24 ++++++++++++- test/test_Sourceforge.py | 73 ++++++++++++++++++++++------------------ 2 files changed, 64 insertions(+), 33 deletions(-) diff --git a/plugins/Sourceforge.py b/plugins/Sourceforge.py index 96c91bb17..b48ca16d1 100644 --- a/plugins/Sourceforge.py +++ b/plugins/Sourceforge.py @@ -81,6 +81,19 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp): _hrefOpts = '&set=custom&_assigned_to=0&_status=1&_category=100&'\ '_group=100&order=artifact_id&sort=DESC' + _resolution = re.compile(r'Resolution: (.+?)', re.I) + _getRes = lambda self, s: '%s: %s' % (ircutils.bold('Resolution'), + self._resolution.search(s).group(1)) + _assigned = re.compile(r'Assigned To: (.+?)', re.I) + _getAssign = lambda self, s: '%s: %s' % (ircutils.bold('Assigned to'), + self._assigned.search(s).group(1)) + _priority = re.compile(r'Priority: (.+?)', re.I) + _getPri = lambda self, s: '%s: %s' % (ircutils.bold('Priority'), + self._priority.search(s).group(1)) + _status = re.compile(r'Status: (.+?)', re.I) + _getStatus = lambda self, s: '%s: %s' % (ircutils.bold('Status'), + self._status.search(s).group(1)) + def _formatResp(self, num, text): """ Parses the Sourceforge query to return a list of tuples that @@ -221,14 +234,23 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp): fd = urllib2.urlopen(url) s = fd.read() fd.close() + searches = (self._getStatus, self._getRes, self._getPri, + self._getAssign) try: (num, desc) = self._sfTitle.search(s).groups() + resp = [desc] linktype = self._linkType.search(s).group(1) + for i in searches: + try: + resp.append('%s' % i(s)) + except AttributeError: + pass if linktype.endswith('es'): linktype = linktype[:-2] else: linktype = linktype[:-1] - irc.reply(msg, '%s #%s: %s' % (linktype, num, desc)) + irc.reply(msg, '%s #%s: %s' % (ircutils.bold(linktype), + ircutils.bold(num), '; '.join(resp))) except AttributeError, e: irc.error(msg, 'That doesn\'t appear to be a proper Sourceforge '\ 'Tracker page.') diff --git a/test/test_Sourceforge.py b/test/test_Sourceforge.py index 0bf43198f..b7e1b05a8 100644 --- a/test/test_Sourceforge.py +++ b/test/test_Sourceforge.py @@ -52,40 +52,49 @@ class SourceforgeTest(PluginTestCase, PluginDocumentation): self.assertNotError('rfes gaim %s' % n) def testSnarfer(self): - self.assertResponse('http://sourceforge.net/tracker/index.php?'\ - 'func=detail&aid=589953&group_id=58965&atid=489447', - 'Bug #589953: Logger doesn\'t log QUITs.') - self.assertResponse('http://sourceforge.net/tracker/index.php?'\ - 'func=detail&aid=712761&group_id=58965&atid=489450', - 'Feature Request #712761: PyPI searching and announcements') - self.assertResponse('http://sourceforge.net/tracker/index.php?'\ - 'func=detail&aid=540223&group_id=235&atid=300235', - 'Patch #540223: update_idle_times patch') - self.assertResponse('http://sourceforge.net/tracker/index.php?'\ - 'func=detail&aid=561547&group_id=235&atid=200235', - 'Support Request #561547: connecting via proxy') - self.assertResponse('http://sourceforge.net/tracker/index.php?'\ - 'func=detail&aid=400942&group_id=235&atid=390395', - 'Plugin #400942: plugins/gen_away.c -- Generate new away msgs on'\ - ' the fly.') + s = r';.*Status.*: \w+;' + self.assertRegexp('http://sourceforge.net/tracker/index.php?'\ + 'func=detail&aid=589953&group_id=58965&atid=489447', s) + self.assertRegexp('http://sourceforge.net/tracker/index.php?'\ + 'func=detail&aid=712761&group_id=58965&atid=489450', s) + self.assertRegexp('http://sourceforge.net/tracker/index.php?'\ + 'func=detail&aid=540223&group_id=235&atid=300235', s) + self.assertRegexp('http://sourceforge.net/tracker/index.php?'\ + 'func=detail&aid=561547&group_id=235&atid=200235', s) + self.assertRegexp('http://sourceforge.net/tracker/index.php?'\ + 'func=detail&aid=400942&group_id=235&atid=390395', s) + + # test that it works without index.php + self.assertNotError('http://sourceforge.net/tracker/?'\ + 'func=detail&aid=540223&group_id=235&atid=300235') + # test that it works with www + self.assertNotError('http://www.sourceforge.net/tracker/index.php?'\ + 'func=detail&aid=540223&group_id=235&atid=300235') + # test that it works with www and without index.php + self.assertNotError('http://www.sourceforge.net/tracker/?'\ + 'func=detail&aid=540223&group_id=235&atid=300235') def testHttpsSnarfer(self): - self.assertResponse('https://sourceforge.net/tracker/index.php?'\ - 'func=detail&aid=589953&group_id=58965&atid=489447', - 'Bug #589953: Logger doesn\'t log QUITs.') - self.assertResponse('https://sourceforge.net/tracker/index.php?'\ - 'func=detail&aid=712761&group_id=58965&atid=489450', - 'Feature Request #712761: PyPI searching and announcements') - self.assertResponse('https://sourceforge.net/tracker/index.php?'\ - 'func=detail&aid=540223&group_id=235&atid=300235', - 'Patch #540223: update_idle_times patch') - self.assertResponse('https://sourceforge.net/tracker/index.php?'\ - 'func=detail&aid=561547&group_id=235&atid=200235', - 'Support Request #561547: connecting via proxy') - self.assertResponse('http://sourceforge.net/tracker/index.php?'\ - 'func=detail&aid=400942&group_id=235&atid=390395', - 'Plugin #400942: plugins/gen_away.c -- Generate new away msgs on'\ - ' the fly.') + s = r';.*Status.*: \w+;' + self.assertRegexp('https://sourceforge.net/tracker/index.php?'\ + 'func=detail&aid=589953&group_id=58965&atid=489447', s) + self.assertRegexp('https://sourceforge.net/tracker/index.php?'\ + 'func=detail&aid=712761&group_id=58965&atid=489450', s) + self.assertRegexp('https://sourceforge.net/tracker/index.php?'\ + 'func=detail&aid=540223&group_id=235&atid=300235', s) + self.assertRegexp('https://sourceforge.net/tracker/index.php?'\ + 'func=detail&aid=561547&group_id=235&atid=200235', s) + self.assertRegexp('http://sourceforge.net/tracker/index.php?'\ + 'func=detail&aid=400942&group_id=235&atid=390395', s) + # test that it works without index.php + self.assertNotError('https://sourceforge.net/tracker/?'\ + 'func=detail&aid=540223&group_id=235&atid=300235') + # test that it works with www + self.assertNotError('https://www.sourceforge.net/tracker/?'\ + 'func=detail&aid=540223&group_id=235&atid=300235') + # test that it works with www and without index.php + self.assertNotError('https://www.sourceforge.net/tracker/index.php?'\ + 'func=detail&aid=540223&group_id=235&atid=300235') # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: