diff --git a/plugins/Sourceforge.py b/plugins/Sourceforge.py index 79a5c1f74..142a076a0 100644 --- a/plugins/Sourceforge.py +++ b/plugins/Sourceforge.py @@ -72,7 +72,7 @@ def configure(onStart, afterConnect, advanced): if yn('Do you want to specify a default project?') == 'y': project = anything('Project name:') if project: - onStart.append('Sourceforge setdefault %s' % project) + onStart.append('Sourceforge defaultproject %s' % project) example = utils.wrapLines(""" <@jamessan|work> @bugs @@ -133,15 +133,16 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, plugins.Toggleable): matches.append((item[0], utils.htmlToText(item[2]))) return matches - def setdefault(self, irc, msg, args): - """ + def defaultproject(self, irc, msg, args): + """[] - Sets the default project to be used with bugs and rfes + Sets the default project to be used with bugs and rfes. If a project + is not specified, clears the default project. """ - project = privmsgs.getArgs(args) + project = privmsgs.getArgs(args, needed=0, optional=1) self.project = project irc.reply(msg, conf.replySuccess) - setdefault = privmsgs.checkCapability(setdefault, 'admin') + defaultproject = privmsgs.checkCapability(defaultproject, 'admin') def _getTrackerInfo(self, irc, msg, url, regex, num): try: @@ -167,7 +168,7 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, plugins.Toggleable): text = fd.read() fd.close() resp = [] - if num != '': + if num: head = '%s ' for match in self._formatResp(num, text): resp.append(head % match) @@ -183,7 +184,8 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, plugins.Toggleable): resp = map(lambda s: utils.ellipsisify(s, 50), resp) irc.reply(msg, '%s' % utils.commaAndify(resp)) return - irc.reply(msg, 'No Trackers were found.') + irc.error(msg, 'No Trackers were found. (%s)' % + conf.replyPossibleBug) except ValueError, e: irc.error(msg, str(e)) except Exception, e: @@ -191,18 +193,16 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, plugins.Toggleable): _bugLink = re.compile(r'"([^"]+)">Bugs') def bugs(self, irc, msg, args): - """[ []] + """[] [] Returns a list of the most recent bugs filed against . - Defaults to searching for supybot bugs. If is specified, the bug - description and link are retrieved. + Defaults to searching for bugs in the project set by defaultproject. + If is specified, the bug description and link are retrieved. """ (project, bugnum) = privmsgs.getArgs(args, needed=0, optional=2) + project = project or self.project if not project: - if self.project is None: - raise callbacks.ArgumentError - else: - project = self.project + raise callbacks.ArgumentError elif not bugnum: try: bugnum = int(project) @@ -214,18 +214,16 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, plugins.Toggleable): _rfeLink = re.compile(r'"([^"]+)">RFE') def rfes(self, irc, msg, args): - """[ []] + """[] [] Returns a list of the most recent RFEs filed against . - Defaults to searching for supybot RFEs. If is specified, the rfe - description and link are retrieved. + Defaults to searching for RFEs in the project set by defaultproject. + If is specified, the rfe description and link are retrieved. """ (project, rfenum) = privmsgs.getArgs(args, needed=0, optional=2) + project = project or self.project if not project: - if self.project is None: - raise callbacks.ArgumentError - else: - project = self.project + raise callbacks.ArgumentError elif not rfenum: try: rfenum = int(project) diff --git a/test/test_Sourceforge.py b/test/test_Sourceforge.py index 05abf696d..9545759a5 100644 --- a/test/test_Sourceforge.py +++ b/test/test_Sourceforge.py @@ -53,9 +53,13 @@ class SourceforgeTest(ChannelPluginTestCase, PluginDocumentation): n = re.search('#(\d+)', m.args[1]).group(1) self.assertNotError('rfes gaim %s' % n) - def testSetdefault(self): - self.assertNotError('setdefault supybot') - self.assertNotError('rfes') + def testDefaultproject(self): + self.assertHelp('bugs') + self.assertNotError('defaultproject supybot') + self.assertNotError('bugs') + m = self.getMsg('bugs') + n = re.search('#(\d+)', m.args[1]).group(1) + self.assertNotError('bugs %s' % n) def testSnarfer(self): s = r'.*Status.*: \w+'