2003-10-16 16:53:42 +02:00
|
|
|
#!/usr/bin/env python
|
2003-10-10 15:47:06 +02:00
|
|
|
|
|
|
|
###
|
2003-10-11 20:40:22 +02:00
|
|
|
# Copyright (c) 2003, James Vega
|
2003-10-10 15:47:06 +02:00
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions are met:
|
|
|
|
#
|
|
|
|
# * Redistributions of source code must retain the above copyright notice,
|
|
|
|
# this list of conditions, and the following disclaimer.
|
|
|
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
# this list of conditions, and the following disclaimer in the
|
|
|
|
# documentation and/or other materials provided with the distribution.
|
|
|
|
# * Neither the name of the author of this software nor the name of
|
|
|
|
# contributors to this software may be used to endorse or promote products
|
|
|
|
# derived from this software without specific prior written consent.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
# POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
###
|
|
|
|
|
|
|
|
"""
|
2003-10-11 20:40:22 +02:00
|
|
|
Accesses Sourceforge.net for various things
|
2003-10-10 15:47:06 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
import re
|
2003-10-11 22:52:35 +02:00
|
|
|
import sets
|
2004-01-13 06:44:43 +01:00
|
|
|
import getopt
|
2003-10-10 15:47:06 +02:00
|
|
|
|
2003-11-15 05:37:04 +01:00
|
|
|
from itertools import ifilter, imap
|
2003-10-10 15:47:06 +02:00
|
|
|
|
2003-10-20 19:52:09 +02:00
|
|
|
import conf
|
2003-10-10 15:47:06 +02:00
|
|
|
import utils
|
2003-11-25 09:23:47 +01:00
|
|
|
__revision__ = "$Id$"
|
|
|
|
|
2003-10-29 07:06:56 +01:00
|
|
|
import plugins
|
2003-10-11 20:40:22 +02:00
|
|
|
import ircutils
|
2003-10-10 15:47:06 +02:00
|
|
|
import privmsgs
|
2003-12-02 07:03:42 +01:00
|
|
|
import webutils
|
2003-10-10 15:47:06 +02:00
|
|
|
import callbacks
|
2003-12-04 00:14:09 +01:00
|
|
|
import configurable
|
2003-10-10 15:47:06 +02:00
|
|
|
|
|
|
|
|
|
|
|
def configure(onStart, afterConnect, advanced):
|
|
|
|
# This will be called by setup.py to configure this module. onStart and
|
|
|
|
# afterConnect are both lists. Append to onStart the commands you would
|
|
|
|
# like to be run when the bot is started; append to afterConnect the
|
|
|
|
# commands you would like to be run when the bot has finished connecting.
|
|
|
|
from questions import expect, anything, something, yn
|
2003-10-21 18:43:02 +02:00
|
|
|
onStart.append('load Sourceforge')
|
2003-11-17 19:10:53 +01:00
|
|
|
print 'The Sourceforge plugin has the functionality to watch for URLs'
|
|
|
|
print 'that match a specific pattern (we call this a snarfer). When'
|
|
|
|
print 'supybot sees such a URL, he will parse the web page for'
|
|
|
|
print 'information and reply with the results.\n'
|
2003-11-22 18:10:41 +01:00
|
|
|
if yn('Do you want this snarfer to be enabled by default?') == 'y':
|
2003-11-17 19:10:53 +01:00
|
|
|
onStart.append('Sourceforge config tracker-snarfer on')
|
2003-10-27 21:24:32 +01:00
|
|
|
|
|
|
|
print 'The bugs and rfes commands of the Sourceforge plugin can be set'
|
|
|
|
print 'to query a default project when no project is specified. If this'
|
|
|
|
print 'project is not set, calling either of those commands will display'
|
|
|
|
print 'the associated help. With the default project set, calling'
|
|
|
|
print 'bugs/rfes with no arguments will find the most recent bugs/rfes'
|
|
|
|
print 'for the default project.\n'
|
|
|
|
if yn('Do you want to specify a default project?') == 'y':
|
|
|
|
project = anything('Project name:')
|
|
|
|
if project:
|
2003-11-08 10:02:30 +01:00
|
|
|
onStart.append('Sourceforge config defaultproject %s' % project)
|
2003-10-10 15:47:06 +02:00
|
|
|
|
2003-11-22 18:10:41 +01:00
|
|
|
print 'Sourceforge is quite the word to type, and it may get annoying'
|
|
|
|
print 'typing it all the time because Supybot makes you use the plugin'
|
|
|
|
print 'name to disambiguate calls to ambiguous commands (i.e., the bug'
|
|
|
|
print 'command is in this plugin and the Bugzilla plugin; if both are'
|
|
|
|
print 'loaded, you\'ll have you type "sourceforge bug ..." to get this'
|
|
|
|
print 'bug command). You may save some time by making an alias for'
|
|
|
|
print '"sourceforge". We like to make it "sf".'
|
|
|
|
if yn('Would you like to add sf as an alias for Sourceforge?') == 'y':
|
2003-11-17 19:10:53 +01:00
|
|
|
if 'load Alias' not in onStart:
|
|
|
|
print 'This depends on the Alias module.'
|
|
|
|
if yn('Would you like to load the Alias plugin now?') == 'y':
|
|
|
|
onStart.append('load Alias')
|
2003-11-20 00:18:34 +01:00
|
|
|
else:
|
|
|
|
print 'Then I can\'t add such an alias.'
|
|
|
|
return
|
|
|
|
onStart.append('alias add sf sourceforge $*')
|
2003-11-17 19:10:53 +01:00
|
|
|
|
2003-11-05 03:13:41 +01:00
|
|
|
class TrackerError(Exception):
|
|
|
|
pass
|
2003-10-10 15:47:06 +02:00
|
|
|
|
2003-12-04 00:14:09 +01:00
|
|
|
class Sourceforge(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin):
|
2003-10-11 20:40:22 +02:00
|
|
|
"""
|
|
|
|
Module for Sourceforge stuff. Currently contains commands to query a
|
|
|
|
project's most recent bugs and rfes.
|
|
|
|
"""
|
2003-10-10 15:47:06 +02:00
|
|
|
threaded = True
|
2003-10-21 23:10:20 +02:00
|
|
|
regexps = ['sfSnarfer']
|
2003-10-10 15:47:06 +02:00
|
|
|
|
2003-10-24 14:38:45 +02:00
|
|
|
_reopts = re.I
|
2004-01-09 00:03:48 +01:00
|
|
|
_infoRe = re.compile(r'<td nowrap>(\d+)</td><td><a href='
|
|
|
|
r'"([^"]+)">([^<]+)</a>', re.I)
|
2004-01-13 06:44:43 +01:00
|
|
|
_hrefOpts = '&set=custom&_assigned_to=0&_status=%s&_category=100' \
|
2004-01-09 00:03:48 +01:00
|
|
|
'&_group=100&order=artifact_id&sort=DESC'
|
2003-11-04 08:03:18 +01:00
|
|
|
_resolution=re.compile(r'<b>(Resolution):</b> <a.+?<br>(.+?)</td>',_reopts)
|
|
|
|
_assigned=re.compile(r'<b>(Assigned To):</b> <a.+?<br>(.+?)</td>', _reopts)
|
2003-11-02 20:46:35 +01:00
|
|
|
_submitted = re.compile(r'<b>(Submitted By):</b><br>([^<]+)</td>', _reopts)
|
|
|
|
_priority = re.compile(r'<b>(Priority):</b> <a.+?<br>(.+?)</td>', _reopts)
|
|
|
|
_status = re.compile(r'<b>(Status):</b> <a.+?<br>(.+?)</td>', _reopts)
|
2004-01-13 03:48:25 +01:00
|
|
|
_regexps =(_resolution, _assigned, _submitted, _priority, _status)
|
2004-01-13 06:44:43 +01:00
|
|
|
_statusOpt = {'any':100, 'open':1, 'closed':2, 'deleted':3, 'pending':4}
|
2003-10-18 16:19:06 +02:00
|
|
|
|
2003-12-04 00:14:09 +01:00
|
|
|
configurables = configurable.Dictionary(
|
|
|
|
[('tracker-snarfer', configurable.BoolType, False,
|
2003-11-08 10:02:30 +01:00
|
|
|
"""Determines whether the bot will reply to SF.net Tracker URLs in
|
|
|
|
the channel with a nice summary of the tracker item."""),
|
2003-12-04 00:14:09 +01:00
|
|
|
('default-project', configurable.StrType, '',
|
2003-11-08 10:02:30 +01:00
|
|
|
"""Sets the default project (used by the bugs/rfes commands in the
|
|
|
|
case that no explicit project is given).""")]
|
|
|
|
)
|
2003-11-05 03:13:41 +01:00
|
|
|
_projectURL = 'http://sourceforge.net/projects/'
|
2003-11-11 16:58:20 +01:00
|
|
|
def __init__(self):
|
2003-12-04 00:14:09 +01:00
|
|
|
configurable.Mixin.__init__(self)
|
2003-11-11 16:58:20 +01:00
|
|
|
callbacks.PrivmsgCommandAndRegexp.__init__(self)
|
|
|
|
|
|
|
|
def die(self):
|
2003-12-04 00:14:09 +01:00
|
|
|
configurable.Mixin.die(self)
|
2003-11-11 16:58:20 +01:00
|
|
|
callbacks.PrivmsgCommandAndRegexp.die(self)
|
2003-10-29 07:06:56 +01:00
|
|
|
|
2003-11-05 03:13:41 +01:00
|
|
|
def _formatResp(self, text, num=''):
|
2003-10-11 20:40:22 +02:00
|
|
|
"""
|
|
|
|
Parses the Sourceforge query to return a list of tuples that
|
|
|
|
contain the bug/rfe information.
|
|
|
|
"""
|
2003-11-05 03:13:41 +01:00
|
|
|
if num:
|
|
|
|
for item in ifilter(lambda s, n=num: s and n in s,
|
2003-10-11 20:40:22 +02:00
|
|
|
self._infoRe.findall(text)):
|
2003-11-05 03:13:41 +01:00
|
|
|
yield (ircutils.bold(utils.htmlToText(item[2])),
|
|
|
|
utils.htmlToText(item[1]))
|
|
|
|
else:
|
2003-10-11 20:40:22 +02:00
|
|
|
for item in ifilter(None, self._infoRe.findall(text)):
|
2003-11-05 03:13:41 +01:00
|
|
|
yield (item[0], utils.htmlToText(item[2]))
|
2003-10-11 20:40:22 +02:00
|
|
|
|
2004-01-13 06:44:43 +01:00
|
|
|
def _getTrackerURL(self, project, regex, status):
|
2003-10-10 15:47:06 +02:00
|
|
|
try:
|
2003-12-02 07:03:42 +01:00
|
|
|
text = webutils.getUrl('%s%s' % (self._projectURL, project))
|
2003-10-27 21:24:32 +01:00
|
|
|
m = regex.search(text)
|
2003-10-10 15:47:06 +02:00
|
|
|
if m is None:
|
2003-11-05 03:13:41 +01:00
|
|
|
raise TrackerError, 'Invalid Tracker page'
|
2003-10-10 15:47:06 +02:00
|
|
|
else:
|
2003-11-05 03:13:41 +01:00
|
|
|
return 'http://sourceforge.net%s%s' % (utils.htmlToText(
|
2004-01-13 06:44:43 +01:00
|
|
|
m.group(1)), self._hrefOpts % self._statusOpt[status])
|
2003-12-03 05:57:30 +01:00
|
|
|
except webutils.WebError, e:
|
2003-11-26 19:21:12 +01:00
|
|
|
raise callbacks.Error, str(e)
|
2003-10-10 15:47:06 +02:00
|
|
|
|
2003-11-05 03:13:41 +01:00
|
|
|
def _getTrackerList(self, url):
|
2003-10-10 15:47:06 +02:00
|
|
|
try:
|
2003-12-02 07:03:42 +01:00
|
|
|
text = webutils.getUrl(url)
|
2003-11-05 03:13:41 +01:00
|
|
|
head = '#%s: %s'
|
|
|
|
resp = [head % entry for entry in self._formatResp(text)]
|
|
|
|
if resp:
|
|
|
|
if len(resp) > 10:
|
2003-11-15 05:37:04 +01:00
|
|
|
resp = imap(lambda s: utils.ellipsisify(s, 50), resp)
|
2003-11-05 03:13:41 +01:00
|
|
|
return '%s' % utils.commaAndify(resp)
|
2004-01-09 00:03:48 +01:00
|
|
|
raise callbacks.Error, 'No Trackers were found. (%s)' % \
|
|
|
|
conf.replyPossibleBug
|
2003-12-03 05:57:30 +01:00
|
|
|
except webutils.WebError, e:
|
2004-01-13 06:44:43 +01:00
|
|
|
raise callbacks.Error, str(e)
|
2003-11-05 03:13:41 +01:00
|
|
|
|
|
|
|
def _getTrackerInfo(self, irc, msg, url, num):
|
|
|
|
try:
|
2003-12-02 07:03:42 +01:00
|
|
|
text = webutils.getUrl(url)
|
2003-11-05 03:13:41 +01:00
|
|
|
head = '%s <http://sourceforge.net%s>'
|
|
|
|
resp = [head % match for match in self._formatResp(text,num)]
|
|
|
|
if resp:
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.reply(resp[0])
|
2003-11-05 03:13:41 +01:00
|
|
|
return
|
2004-01-09 00:03:48 +01:00
|
|
|
irc.errorPossibleBug('No Trackers were found.')
|
2003-12-03 05:57:30 +01:00
|
|
|
except webutils.WebError, e:
|
2004-01-13 06:44:43 +01:00
|
|
|
irc.error(str(e))
|
2003-10-10 15:47:06 +02:00
|
|
|
|
2003-10-27 21:24:32 +01:00
|
|
|
_bugLink = re.compile(r'"([^"]+)">Bugs')
|
|
|
|
def bugs(self, irc, msg, args):
|
2004-01-13 06:44:43 +01:00
|
|
|
"""[--{any,open,closed,deleted,pending}] [<project>]
|
2003-10-27 21:24:32 +01:00
|
|
|
|
|
|
|
Returns a list of the most recent bugs filed against <project>.
|
2004-01-13 06:44:43 +01:00
|
|
|
<project> is not needed if there is a default project set. Search
|
|
|
|
defaults to open bugs.
|
2003-10-27 21:24:32 +01:00
|
|
|
"""
|
2004-01-13 06:44:43 +01:00
|
|
|
(optlist, rest) = getopt.getopt(args, '', self._statusOpt.keys())
|
|
|
|
project = privmsgs.getArgs(rest, required=0, optional=1)
|
|
|
|
status = 'open'
|
|
|
|
for (option, _) in optlist:
|
|
|
|
option = option.lstrip('-').lower()
|
|
|
|
if option in self._statusOpt:
|
|
|
|
status = option
|
2003-11-11 17:04:27 +01:00
|
|
|
try:
|
|
|
|
int(project)
|
2004-01-09 00:03:48 +01:00
|
|
|
# They want the bug command, they're giving us an id#.
|
|
|
|
s = 'Use the bug command to get information about a specific bug.'
|
|
|
|
irc.error(s)
|
2003-11-11 17:04:27 +01:00
|
|
|
return
|
|
|
|
except ValueError:
|
|
|
|
pass
|
2003-10-27 21:24:32 +01:00
|
|
|
if not project:
|
2003-11-08 10:02:30 +01:00
|
|
|
project = self.configurables.get('default-project', msg.args[0])
|
|
|
|
if not project:
|
|
|
|
raise callbacks.ArgumentError
|
2003-11-05 03:13:41 +01:00
|
|
|
try:
|
2004-01-13 06:44:43 +01:00
|
|
|
url = self._getTrackerURL(project, self._bugLink, status)
|
2003-11-11 17:04:27 +01:00
|
|
|
except TrackerError, e:
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('%s. Can\'t find the Bugs link.' % e)
|
2003-11-05 03:13:41 +01:00
|
|
|
return
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.reply(self._getTrackerList(url))
|
2003-11-05 03:13:41 +01:00
|
|
|
|
2003-12-09 01:39:16 +01:00
|
|
|
def bug(self, irc, msg, args):
|
2004-01-13 06:44:43 +01:00
|
|
|
"""[--{any,open,closed,deleted,pending}] [<project>] <num>
|
2003-12-09 01:39:16 +01:00
|
|
|
|
|
|
|
Returns a description of the bug with Tracker id <num> and the
|
|
|
|
corresponding Tracker URL. <project> is not needed if there is a
|
2004-01-13 06:44:43 +01:00
|
|
|
default project set. Search defaults to open bugs.
|
2003-12-09 01:39:16 +01:00
|
|
|
"""
|
2004-01-13 06:44:43 +01:00
|
|
|
(optlist, rest) = getopt.getopt(args, '', self._statusOpt.keys())
|
|
|
|
(project, bugnum) = privmsgs.getArgs(rest, optional=1)
|
|
|
|
status = 'open'
|
|
|
|
for (option, _) in optlist:
|
|
|
|
option = option.lstrip('-').lower()
|
|
|
|
if option in self._statusOpt:
|
|
|
|
status = option
|
2003-12-09 01:39:16 +01:00
|
|
|
if not bugnum:
|
|
|
|
try:
|
|
|
|
int(project)
|
|
|
|
except ValueError:
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('"%s" is not a proper bugnumber.' % project)
|
2003-12-09 01:39:16 +01:00
|
|
|
return
|
|
|
|
bugnum = project
|
|
|
|
project = self.configurables.get('default-project', msg.args[0])
|
|
|
|
if not project:
|
|
|
|
raise callbacks.ArgumentError
|
|
|
|
try:
|
2004-01-13 06:44:43 +01:00
|
|
|
url = self._getTrackerURL(project, self._bugLink, status)
|
2004-01-13 06:56:17 +01:00
|
|
|
#self.log.warning(url)
|
2003-12-09 01:39:16 +01:00
|
|
|
except TrackerError, e:
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('%s. Can\'t find the Bugs link.' % e)
|
2003-12-09 01:39:16 +01:00
|
|
|
return
|
|
|
|
self._getTrackerInfo(irc, msg, url, bugnum)
|
|
|
|
|
2003-10-10 15:47:06 +02:00
|
|
|
_rfeLink = re.compile(r'"([^"]+)">RFE')
|
|
|
|
def rfes(self, irc, msg, args):
|
2004-01-13 06:44:43 +01:00
|
|
|
"""[--{any,open,closed,deleted,pending}] [<project>]
|
2003-10-10 15:47:06 +02:00
|
|
|
|
2003-10-11 20:40:22 +02:00
|
|
|
Returns a list of the most recent RFEs filed against <project>.
|
2004-01-13 06:44:43 +01:00
|
|
|
<project> is not needed if there is a default project set. Search
|
|
|
|
defaults to open RFEs.
|
2003-10-10 15:47:06 +02:00
|
|
|
"""
|
2004-01-13 06:44:43 +01:00
|
|
|
(optlist, rest) = getopt.getopt(args, '', self._statusOpt.keys())
|
|
|
|
project = privmsgs.getArgs(rest, required=0, optional=1)
|
|
|
|
status = 'open'
|
|
|
|
for (option, _) in optlist:
|
|
|
|
option = option.lstrip('-').lower()
|
|
|
|
if option in self._statusOpt:
|
|
|
|
status = option
|
2003-11-11 17:04:27 +01:00
|
|
|
try:
|
|
|
|
int(project)
|
2004-01-09 00:03:48 +01:00
|
|
|
# They want a specific RFE, they gave us its id#.
|
|
|
|
s = 'Use the rfe command to get information about a specific rfe.'
|
|
|
|
irc.error(s)
|
2003-11-11 17:04:27 +01:00
|
|
|
return
|
|
|
|
except ValueError:
|
|
|
|
pass
|
2003-10-10 15:47:06 +02:00
|
|
|
if not project:
|
2003-11-08 10:02:30 +01:00
|
|
|
project = self.configurables.get('default-project', msg.args[0])
|
|
|
|
if not project:
|
|
|
|
raise callbacks.ArgumentError
|
2003-11-05 03:13:41 +01:00
|
|
|
try:
|
2004-01-13 06:44:43 +01:00
|
|
|
url = self._getTrackerURL(project, self._rfeLink, status)
|
2003-11-05 03:13:41 +01:00
|
|
|
except TrackerError, e:
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('%s. Can\'t find the RFEs link.' % e)
|
2003-11-05 03:13:41 +01:00
|
|
|
return
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.reply(self._getTrackerList(url))
|
2003-11-05 03:13:41 +01:00
|
|
|
|
2003-12-09 01:39:16 +01:00
|
|
|
def rfe(self, irc, msg, args):
|
2004-01-13 06:44:43 +01:00
|
|
|
"""[--{any,open,closed,deleted,pending}] [<project>] <num>
|
2003-11-05 03:13:41 +01:00
|
|
|
|
2003-12-09 01:39:16 +01:00
|
|
|
Returns a description of the bug with Tracker id <num> and the
|
|
|
|
corresponding Tracker URL. <project> is not needed if there is a
|
2004-01-13 06:44:43 +01:00
|
|
|
default project set. Search defaults to open RFEs.
|
2003-11-05 03:13:41 +01:00
|
|
|
"""
|
2004-01-13 06:44:43 +01:00
|
|
|
(optlist, rest) = getopt.getopt(args, '', self._statusOpt.keys())
|
|
|
|
(project, rfenum) = privmsgs.getArgs(rest, optional=1)
|
|
|
|
status = 'open'
|
|
|
|
for (option, _) in optlist:
|
|
|
|
option = option.lstrip('-').lower()
|
|
|
|
if option in self._statusOpt:
|
|
|
|
status = option
|
2003-12-09 01:39:16 +01:00
|
|
|
if not rfenum:
|
|
|
|
try:
|
|
|
|
int(project)
|
|
|
|
except ValueError:
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('"%s" is not a proper rfenumber.' % project)
|
2003-12-09 01:39:16 +01:00
|
|
|
return
|
|
|
|
rfenum = project
|
|
|
|
project = self.configurables.get('default-project', msg.args[0])
|
|
|
|
if not project:
|
|
|
|
raise callbacks.ArgumentError
|
2003-11-05 03:13:41 +01:00
|
|
|
try:
|
2004-01-13 06:44:43 +01:00
|
|
|
url = self._getTrackerURL(project, self._rfeLink, status)
|
2003-12-09 01:39:16 +01:00
|
|
|
except TrackerError, e:
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('%s. Can\'t find the RFEs link.' % e)
|
2003-11-05 03:13:41 +01:00
|
|
|
return
|
2003-12-09 01:39:16 +01:00
|
|
|
self._getTrackerInfo(irc, msg, url, rfenum)
|
2003-10-10 15:47:06 +02:00
|
|
|
|
2003-11-02 20:46:35 +01:00
|
|
|
_bold = lambda self, m: (ircutils.bold(m[0]),) + m[1:]
|
2003-10-11 22:52:35 +02:00
|
|
|
_sfTitle = re.compile(r'Detail:(\d+) - ([^<]+)</title>', re.I)
|
|
|
|
_linkType = re.compile(r'(\w+ \w+|\w+): Tracker Detailed View', re.I)
|
2003-10-21 14:20:23 +02:00
|
|
|
def sfSnarfer(self, irc, msg, match):
|
2003-10-30 01:13:00 +01:00
|
|
|
r"https?://(?:www\.)?(?:sourceforge|sf)\.net/tracker/" \
|
|
|
|
r".*\?(?:&?func=detail|&?aid=\d+|&?group_id=\d+|&?atid=\d+){4}"
|
2003-11-08 10:02:30 +01:00
|
|
|
if not self.configurables.get('tracker-snarfer', channel=msg.args[0]):
|
2003-10-20 19:52:09 +02:00
|
|
|
return
|
2003-10-11 22:52:35 +02:00
|
|
|
try:
|
2003-11-02 20:46:35 +01:00
|
|
|
url = match.group(0)
|
2003-12-02 07:03:42 +01:00
|
|
|
s = webutils.getUrl(url)
|
2003-11-02 20:46:35 +01:00
|
|
|
resp = []
|
|
|
|
head = ''
|
|
|
|
m = self._linkType.search(s)
|
|
|
|
n = self._sfTitle.search(s)
|
|
|
|
if m and n:
|
|
|
|
linktype = m.group(1)
|
|
|
|
linktype = utils.depluralize(linktype)
|
|
|
|
(num, desc) = n.groups()
|
|
|
|
head = '%s #%s:' % (ircutils.bold(linktype), num)
|
|
|
|
resp.append(desc)
|
|
|
|
else:
|
2004-01-09 00:03:48 +01:00
|
|
|
self.log.warning('Invalid Tracker page snarfed: %s', url)
|
2004-01-13 03:48:25 +01:00
|
|
|
for r in self._regexps:
|
2003-12-09 01:39:16 +01:00
|
|
|
m = r.search(s)
|
|
|
|
if m:
|
|
|
|
resp.append('%s: %s' % self._bold(m.groups()))
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.reply('%s #%s: %s' % (ircutils.bold(linktype),
|
2003-12-09 01:39:16 +01:00
|
|
|
ircutils.bold(num), '; '.join(resp)), prefixName = False)
|
2003-12-03 05:57:30 +01:00
|
|
|
except webutils.WebError, e:
|
2003-11-26 19:21:12 +01:00
|
|
|
self.log.warning(str(e))
|
2003-11-08 10:02:30 +01:00
|
|
|
sfSnarfer = privmsgs.urlSnarfer(sfSnarfer)
|
2003-10-11 22:52:35 +02:00
|
|
|
|
2003-10-21 18:43:02 +02:00
|
|
|
Class = Sourceforge
|
2003-10-10 15:47:06 +02:00
|
|
|
|
|
|
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|