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):
|
def _getTrackerInfo(self, irc, msg, url, num):
|
||||||
try:
|
try:
|
||||||
text = webutils.getUrl(url)
|
text = webutils.getUrl(url)
|
||||||
|
#self.log.warning(text)
|
||||||
head = '%s <http://sourceforge.net%s>'
|
head = '%s <http://sourceforge.net%s>'
|
||||||
resp = [head % match for match in self._formatResp(text,num)]
|
resp = [head % match for match in self._formatResp(text,num)]
|
||||||
if resp:
|
if resp:
|
||||||
|
@ -183,7 +184,7 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin):
|
||||||
irc.error(msg, 'No Trackers were found. (%s)' %
|
irc.error(msg, 'No Trackers were found. (%s)' %
|
||||||
conf.replyPossibleBug)
|
conf.replyPossibleBug)
|
||||||
except webutils.WebError, e:
|
except webutils.WebError, e:
|
||||||
irc.error(msg, e.msg())
|
irc.error(msg, str(e))
|
||||||
|
|
||||||
_bugLink = re.compile(r'"([^"]+)">Bugs')
|
_bugLink = re.compile(r'"([^"]+)">Bugs')
|
||||||
def bugs(self, irc, msg, args):
|
def bugs(self, irc, msg, args):
|
||||||
|
@ -195,8 +196,8 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin):
|
||||||
project = privmsgs.getArgs(args, required=0, optional=1)
|
project = privmsgs.getArgs(args, required=0, optional=1)
|
||||||
try:
|
try:
|
||||||
int(project)
|
int(project)
|
||||||
irc.error(msg, 'Use the bug command to get information about a '\
|
irc.error(msg, 'Use the tracker command to get information '\
|
||||||
'specific bug.')
|
'about a specific bug.')
|
||||||
return
|
return
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
@ -211,31 +212,6 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin):
|
||||||
return
|
return
|
||||||
irc.reply(msg, self._getTrackerList(url))
|
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')
|
_rfeLink = re.compile(r'"([^"]+)">RFE')
|
||||||
def rfes(self, irc, msg, args):
|
def rfes(self, irc, msg, args):
|
||||||
"""[<project>]
|
"""[<project>]
|
||||||
|
@ -246,8 +222,8 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin):
|
||||||
project = privmsgs.getArgs(args, required=0, optional=1)
|
project = privmsgs.getArgs(args, required=0, optional=1)
|
||||||
try:
|
try:
|
||||||
int(project)
|
int(project)
|
||||||
irc.error(msg, 'Use the rfe command to get information about a '\
|
irc.error(msg, 'Use the tracker command to get information '\
|
||||||
'specific rfe.')
|
'about a specific rfe.')
|
||||||
return
|
return
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
@ -262,30 +238,19 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin):
|
||||||
return
|
return
|
||||||
irc.reply(msg, self._getTrackerList(url))
|
irc.reply(msg, self._getTrackerList(url))
|
||||||
|
|
||||||
def rfe(self, irc, msg, args):
|
def tracker(self, irc, msg, args):
|
||||||
"""[<project>] <num>
|
"""<id>
|
||||||
|
|
||||||
Returns a description of the bug with Tracker id <num> and the
|
Returns a description and URL of the Tracker with id <id>
|
||||||
corresponding Tracker URL. <project> is not needed if there is a
|
|
||||||
default project set.
|
|
||||||
"""
|
"""
|
||||||
(project, rfenum) = privmsgs.getArgs(args, optional=1)
|
id = privmsgs.getArgs(args)
|
||||||
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
|
|
||||||
try:
|
try:
|
||||||
url = self._getTrackerURL(project, self._rfeLink)
|
int(id)
|
||||||
except TrackerError, e:
|
except ValueError:
|
||||||
irc.error(msg, '%s. Can\'t find the RFEs link.' % e)
|
irc.error(msg, 'Tracker id must be an integer')
|
||||||
return
|
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:]
|
_bold = lambda self, m: (ircutils.bold(m[0]),) + m[1:]
|
||||||
_sfTitle = re.compile(r'Detail:(\d+) - ([^<]+)</title>', re.I)
|
_sfTitle = re.compile(r'Detail:(\d+) - ([^<]+)</title>', re.I)
|
||||||
|
@ -308,16 +273,16 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin):
|
||||||
(num, desc) = n.groups()
|
(num, desc) = n.groups()
|
||||||
head = '%s #%s:' % (ircutils.bold(linktype), num)
|
head = '%s #%s:' % (ircutils.bold(linktype), num)
|
||||||
resp.append(desc)
|
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:
|
else:
|
||||||
s = '%s does not appear to be a proper Sourceforge ' \
|
s = '%s does not appear to be a proper Sourceforge ' \
|
||||||
'Tracker page (%s)' % (url, conf.replyPossibleBug)
|
'Tracker page (%s)' % (url, conf.replyPossibleBug)
|
||||||
self.log.warning(s)
|
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:
|
except webutils.WebError, e:
|
||||||
self.log.warning(str(e))
|
self.log.warning(str(e))
|
||||||
sfSnarfer = privmsgs.urlSnarfer(sfSnarfer)
|
sfSnarfer = privmsgs.urlSnarfer(sfSnarfer)
|
||||||
|
|
|
@ -35,15 +35,6 @@ from testsupport import *
|
||||||
|
|
||||||
class SourceforgeTest(ChannelPluginTestCase, PluginDocumentation):
|
class SourceforgeTest(ChannelPluginTestCase, PluginDocumentation):
|
||||||
plugins = ('Sourceforge',)
|
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):
|
def testBugs(self):
|
||||||
self.assertHelp('bugs')
|
self.assertHelp('bugs')
|
||||||
self.assertNotError('config defaultproject supybot')
|
self.assertNotError('config defaultproject supybot')
|
||||||
|
@ -53,13 +44,12 @@ class SourceforgeTest(ChannelPluginTestCase, PluginDocumentation):
|
||||||
self.assertNotError('config defaultproject')
|
self.assertNotError('config defaultproject')
|
||||||
self.assertRegexp('bugs 83423', 'Use the bug command')
|
self.assertRegexp('bugs 83423', 'Use the bug command')
|
||||||
|
|
||||||
def testRfe(self):
|
def testTracker(self):
|
||||||
|
self.assertError('tracker foo')
|
||||||
m = self.getMsg('rfes gaim')
|
m = self.getMsg('rfes gaim')
|
||||||
self.failUnless(m, 'No response from Sourceforge.')
|
self.failUnless(m, 'No response from Sourceforge.')
|
||||||
n = re.search('#(\d+)', m.args[1]).group(1)
|
n = re.search('#(\d+)', m.args[1]).group(1)
|
||||||
self.assertNotError('rfe gaim %s' % n)
|
self.assertNotError('tracker %s' % n)
|
||||||
self.assertError('rfe gaim')
|
|
||||||
self.assertRegexp('rfe lakdf 9', 'find the RFEs')
|
|
||||||
|
|
||||||
def testRfes(self):
|
def testRfes(self):
|
||||||
self.assertHelp('rfes')
|
self.assertHelp('rfes')
|
||||||
|
@ -74,11 +64,6 @@ class SourceforgeTest(ChannelPluginTestCase, PluginDocumentation):
|
||||||
self.assertHelp('bugs')
|
self.assertHelp('bugs')
|
||||||
self.assertNotError('config defaultproject supybot')
|
self.assertNotError('config defaultproject supybot')
|
||||||
self.assertNotError('bugs')
|
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 ""')
|
self.assertNotError('config defaultproject ""')
|
||||||
|
|
||||||
def testSnarfer(self):
|
def testSnarfer(self):
|
||||||
|
|
Loading…
Reference in New Issue