From 0857e3aca6b0fd872fb977e40fb3e17d38139105 Mon Sep 17 00:00:00 2001 From: James Vega Date: Thu, 4 Dec 2003 02:18:55 +0000 Subject: [PATCH] with Sourceforge.bug and Sourceforge.rfe's powers combined, we have Sourceforge.tracker! --- plugins/Sourceforge.py | 77 +++++++++++----------------------------- test/test_Sourceforge.py | 21 ++--------- 2 files changed, 24 insertions(+), 74 deletions(-) diff --git a/plugins/Sourceforge.py b/plugins/Sourceforge.py index 90f7b8c45..e9edcee1c 100644 --- a/plugins/Sourceforge.py +++ b/plugins/Sourceforge.py @@ -175,6 +175,7 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin): def _getTrackerInfo(self, irc, msg, url, num): try: text = webutils.getUrl(url) + #self.log.warning(text) head = '%s ' resp = [head % match for match in self._formatResp(text,num)] if resp: @@ -183,7 +184,7 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin): irc.error(msg, 'No Trackers were found. (%s)' % conf.replyPossibleBug) except webutils.WebError, e: - irc.error(msg, e.msg()) + irc.error(msg, str(e)) _bugLink = re.compile(r'"([^"]+)">Bugs') def bugs(self, irc, msg, args): @@ -195,8 +196,8 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin): project = privmsgs.getArgs(args, required=0, optional=1) try: int(project) - irc.error(msg, 'Use the bug command to get information about a '\ - 'specific bug.') + irc.error(msg, 'Use the tracker command to get information '\ + 'about a specific bug.') return except ValueError: pass @@ -211,31 +212,6 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin): return irc.reply(msg, self._getTrackerList(url)) - def bug(self, irc, msg, args): - """[] - - Returns a description of the bug with Tracker id and the - corresponding Tracker URL. is not needed if there is a - default project set. - """ - (project, bugnum) = privmsgs.getArgs(args, optional=1) - if not bugnum: - try: - int(project) - except ValueError: - irc.error(msg, '"%s" is not a proper bugnumber.' % project) - return - bugnum = project - project = self.configurables.get('default-project', msg.args[0]) - if not project: - raise callbacks.ArgumentError - try: - url = self._getTrackerURL(project, self._bugLink) - except TrackerError, e: - irc.error(msg, '%s. Can\'t find the Bugs link.' % e) - return - self._getTrackerInfo(irc, msg, url, bugnum) - _rfeLink = re.compile(r'"([^"]+)">RFE') def rfes(self, irc, msg, args): """[] @@ -246,8 +222,8 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin): project = privmsgs.getArgs(args, required=0, optional=1) try: int(project) - irc.error(msg, 'Use the rfe command to get information about a '\ - 'specific rfe.') + irc.error(msg, 'Use the tracker command to get information '\ + 'about a specific rfe.') return except ValueError: pass @@ -262,30 +238,19 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin): return irc.reply(msg, self._getTrackerList(url)) - def rfe(self, irc, msg, args): - """[] + def tracker(self, irc, msg, args): + """ - Returns a description of the bug with Tracker id and the - corresponding Tracker URL. is not needed if there is a - default project set. + Returns a description and URL of the Tracker with id """ - (project, rfenum) = privmsgs.getArgs(args, optional=1) - if not rfenum: - try: - int(project) - except ValueError: - irc.error(msg, '"%s" is not a proper rfenumber.' % project) - return - rfenum = project - project = self.configurables.get('default-project', msg.args[0]) - if not project: - raise callbacks.ArgumentError + id = privmsgs.getArgs(args) try: - url = self._getTrackerURL(project, self._rfeLink) - except TrackerError, e: - irc.error(msg, '%s. Can\'t find the RFEs link.' % e) + int(id) + except ValueError: + irc.error(msg, 'Tracker id must be an integer') return - self._getTrackerInfo(irc, msg, url, rfenum) + url = 'http://sourceforge.net/support/tracker.php?aid=%s' % id + self._getTrackerInfo(irc, msg, url, id) _bold = lambda self, m: (ircutils.bold(m[0]),) + m[1:] _sfTitle = re.compile(r'Detail:(\d+) - ([^<]+)', re.I) @@ -308,16 +273,16 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin): (num, desc) = n.groups() head = '%s #%s:' % (ircutils.bold(linktype), num) resp.append(desc) + for r in self._res: + m = r.search(s) + if m: + resp.append('%s: %s' % self._bold(m.groups())) + irc.reply(msg, '%s #%s: %s' % (ircutils.bold(linktype), + ircutils.bold(num), '; '.join(resp)), prefixName = False) else: s = '%s does not appear to be a proper Sourceforge ' \ 'Tracker page (%s)' % (url, conf.replyPossibleBug) self.log.warning(s) - for r in self._res: - m = r.search(s) - if m: - resp.append('%s: %s' % self._bold(m.groups())) - irc.reply(msg, '%s #%s: %s' % (ircutils.bold(linktype), - ircutils.bold(num), '; '.join(resp)), prefixName = False) except webutils.WebError, e: self.log.warning(str(e)) sfSnarfer = privmsgs.urlSnarfer(sfSnarfer) diff --git a/test/test_Sourceforge.py b/test/test_Sourceforge.py index afc521f4f..8d2202068 100644 --- a/test/test_Sourceforge.py +++ b/test/test_Sourceforge.py @@ -35,15 +35,6 @@ from testsupport import * class SourceforgeTest(ChannelPluginTestCase, PluginDocumentation): plugins = ('Sourceforge',) - def testBug(self): - self.assertHelp('bug') - m = self.getMsg('bugs gaim') - self.failUnless(m, 'No response from Sourceforge.') - n = re.search('#(\d+)', m.args[1]).group(1) - self.assertNotError('bug gaim %s' % n) - self.assertError('bug gaim') - self.assertRegexp('bug lkadf 9', 'find the Bugs') - def testBugs(self): self.assertHelp('bugs') self.assertNotError('config defaultproject supybot') @@ -53,13 +44,12 @@ class SourceforgeTest(ChannelPluginTestCase, PluginDocumentation): self.assertNotError('config defaultproject') self.assertRegexp('bugs 83423', 'Use the bug command') - def testRfe(self): + def testTracker(self): + self.assertError('tracker foo') m = self.getMsg('rfes gaim') self.failUnless(m, 'No response from Sourceforge.') n = re.search('#(\d+)', m.args[1]).group(1) - self.assertNotError('rfe gaim %s' % n) - self.assertError('rfe gaim') - self.assertRegexp('rfe lakdf 9', 'find the RFEs') + self.assertNotError('tracker %s' % n) def testRfes(self): self.assertHelp('rfes') @@ -74,11 +64,6 @@ class SourceforgeTest(ChannelPluginTestCase, PluginDocumentation): self.assertHelp('bugs') self.assertNotError('config defaultproject supybot') self.assertNotError('bugs') - m = self.getMsg('bugs') - n = re.search('#(\d+)', m.args[1]).group(1) - self.assertNotError('bug supybot %s' % n) - # This should have the same effect as calling 'bug supybot %s' - self.assertNotError('bug %s' % n) self.assertNotError('config defaultproject ""') def testSnarfer(self):