mirror of https://github.com/Mikaela/Limnoria.git
with Sourceforge.bug and Sourceforge.rfe's powers combined, we have
Sourceforge.tracker!
This commit is contained in:
parent
93d3d78ccb
commit
0857e3aca6
|
@ -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 <http://sourceforge.net%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):
|
||||
"""[<project>] <num>
|
||||
|
||||
Returns a description of the bug with Tracker id <num> and the
|
||||
corresponding Tracker URL. <project> 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):
|
||||
"""[<project>]
|
||||
|
@ -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):
|
||||
"""[<project>] <num>
|
||||
def tracker(self, irc, msg, args):
|
||||
"""<id>
|
||||
|
||||
Returns a description of the bug with Tracker id <num> and the
|
||||
corresponding Tracker URL. <project> is not needed if there is a
|
||||
default project set.
|
||||
Returns a description and URL of the Tracker with id <id>
|
||||
"""
|
||||
(project, rfenum) = privmsgs.getArgs(args, optional=1)
|
||||
if not rfenum:
|
||||
id = privmsgs.getArgs(args)
|
||||
try:
|
||||
int(project)
|
||||
int(id)
|
||||
except ValueError:
|
||||
irc.error(msg, '"%s" is not a proper rfenumber.' % project)
|
||||
irc.error(msg, 'Tracker id must be an integer')
|
||||
return
|
||||
rfenum = project
|
||||
project = self.configurables.get('default-project', msg.args[0])
|
||||
if not project:
|
||||
raise callbacks.ArgumentError
|
||||
try:
|
||||
url = self._getTrackerURL(project, self._rfeLink)
|
||||
except TrackerError, e:
|
||||
irc.error(msg, '%s. Can\'t find the RFEs link.' % e)
|
||||
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+) - ([^<]+)</title>', 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)
|
||||
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)
|
||||
else:
|
||||
s = '%s does not appear to be a proper Sourceforge ' \
|
||||
'Tracker page (%s)' % (url, conf.replyPossibleBug)
|
||||
self.log.warning(s)
|
||||
except webutils.WebError, e:
|
||||
self.log.warning(str(e))
|
||||
sfSnarfer = privmsgs.urlSnarfer(sfSnarfer)
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue