mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-30 14:14:37 +01:00
Added more information to the snarfer and cleaned up the related tests.
This commit is contained in:
parent
aab016ddd1
commit
29a3264126
@ -81,6 +81,19 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
_hrefOpts = '&set=custom&_assigned_to=0&_status=1&_category=100&'\
|
_hrefOpts = '&set=custom&_assigned_to=0&_status=1&_category=100&'\
|
||||||
'_group=100&order=artifact_id&sort=DESC'
|
'_group=100&order=artifact_id&sort=DESC'
|
||||||
|
|
||||||
|
_resolution = re.compile(r'<b>Resolution:</b> <a.+?<br>(.+?)</td>', re.I)
|
||||||
|
_getRes = lambda self, s: '%s: %s' % (ircutils.bold('Resolution'),
|
||||||
|
self._resolution.search(s).group(1))
|
||||||
|
_assigned = re.compile(r'<b>Assigned To:</b> <a.+?<br>(.+?)</td>', re.I)
|
||||||
|
_getAssign = lambda self, s: '%s: %s' % (ircutils.bold('Assigned to'),
|
||||||
|
self._assigned.search(s).group(1))
|
||||||
|
_priority = re.compile(r'<b>Priority:</b> <a.+?<br>(.+?)</td>', re.I)
|
||||||
|
_getPri = lambda self, s: '%s: %s' % (ircutils.bold('Priority'),
|
||||||
|
self._priority.search(s).group(1))
|
||||||
|
_status = re.compile(r'<b>Status:</b> <a.+?<br>(.+?)</td>', re.I)
|
||||||
|
_getStatus = lambda self, s: '%s: %s' % (ircutils.bold('Status'),
|
||||||
|
self._status.search(s).group(1))
|
||||||
|
|
||||||
def _formatResp(self, num, text):
|
def _formatResp(self, num, text):
|
||||||
"""
|
"""
|
||||||
Parses the Sourceforge query to return a list of tuples that
|
Parses the Sourceforge query to return a list of tuples that
|
||||||
@ -221,14 +234,23 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
fd = urllib2.urlopen(url)
|
fd = urllib2.urlopen(url)
|
||||||
s = fd.read()
|
s = fd.read()
|
||||||
fd.close()
|
fd.close()
|
||||||
|
searches = (self._getStatus, self._getRes, self._getPri,
|
||||||
|
self._getAssign)
|
||||||
try:
|
try:
|
||||||
(num, desc) = self._sfTitle.search(s).groups()
|
(num, desc) = self._sfTitle.search(s).groups()
|
||||||
|
resp = [desc]
|
||||||
linktype = self._linkType.search(s).group(1)
|
linktype = self._linkType.search(s).group(1)
|
||||||
|
for i in searches:
|
||||||
|
try:
|
||||||
|
resp.append('%s' % i(s))
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
if linktype.endswith('es'):
|
if linktype.endswith('es'):
|
||||||
linktype = linktype[:-2]
|
linktype = linktype[:-2]
|
||||||
else:
|
else:
|
||||||
linktype = linktype[:-1]
|
linktype = linktype[:-1]
|
||||||
irc.reply(msg, '%s #%s: %s' % (linktype, num, desc))
|
irc.reply(msg, '%s #%s: %s' % (ircutils.bold(linktype),
|
||||||
|
ircutils.bold(num), '; '.join(resp)))
|
||||||
except AttributeError, e:
|
except AttributeError, e:
|
||||||
irc.error(msg, 'That doesn\'t appear to be a proper Sourceforge '\
|
irc.error(msg, 'That doesn\'t appear to be a proper Sourceforge '\
|
||||||
'Tracker page.')
|
'Tracker page.')
|
||||||
|
@ -52,40 +52,49 @@ class SourceforgeTest(PluginTestCase, PluginDocumentation):
|
|||||||
self.assertNotError('rfes gaim %s' % n)
|
self.assertNotError('rfes gaim %s' % n)
|
||||||
|
|
||||||
def testSnarfer(self):
|
def testSnarfer(self):
|
||||||
self.assertResponse('http://sourceforge.net/tracker/index.php?'\
|
s = r';.*Status.*: \w+;'
|
||||||
'func=detail&aid=589953&group_id=58965&atid=489447',
|
self.assertRegexp('http://sourceforge.net/tracker/index.php?'\
|
||||||
'Bug #589953: Logger doesn\'t log QUITs.')
|
'func=detail&aid=589953&group_id=58965&atid=489447', s)
|
||||||
self.assertResponse('http://sourceforge.net/tracker/index.php?'\
|
self.assertRegexp('http://sourceforge.net/tracker/index.php?'\
|
||||||
'func=detail&aid=712761&group_id=58965&atid=489450',
|
'func=detail&aid=712761&group_id=58965&atid=489450', s)
|
||||||
'Feature Request #712761: PyPI searching and announcements')
|
self.assertRegexp('http://sourceforge.net/tracker/index.php?'\
|
||||||
self.assertResponse('http://sourceforge.net/tracker/index.php?'\
|
'func=detail&aid=540223&group_id=235&atid=300235', s)
|
||||||
'func=detail&aid=540223&group_id=235&atid=300235',
|
self.assertRegexp('http://sourceforge.net/tracker/index.php?'\
|
||||||
'Patch #540223: update_idle_times patch')
|
'func=detail&aid=561547&group_id=235&atid=200235', s)
|
||||||
self.assertResponse('http://sourceforge.net/tracker/index.php?'\
|
self.assertRegexp('http://sourceforge.net/tracker/index.php?'\
|
||||||
'func=detail&aid=561547&group_id=235&atid=200235',
|
'func=detail&aid=400942&group_id=235&atid=390395', s)
|
||||||
'Support Request #561547: connecting via proxy')
|
|
||||||
self.assertResponse('http://sourceforge.net/tracker/index.php?'\
|
# test that it works without index.php
|
||||||
'func=detail&aid=400942&group_id=235&atid=390395',
|
self.assertNotError('http://sourceforge.net/tracker/?'\
|
||||||
'Plugin #400942: plugins/gen_away.c -- Generate new away msgs on'\
|
'func=detail&aid=540223&group_id=235&atid=300235')
|
||||||
' the fly.')
|
# test that it works with www
|
||||||
|
self.assertNotError('http://www.sourceforge.net/tracker/index.php?'\
|
||||||
|
'func=detail&aid=540223&group_id=235&atid=300235')
|
||||||
|
# test that it works with www and without index.php
|
||||||
|
self.assertNotError('http://www.sourceforge.net/tracker/?'\
|
||||||
|
'func=detail&aid=540223&group_id=235&atid=300235')
|
||||||
|
|
||||||
def testHttpsSnarfer(self):
|
def testHttpsSnarfer(self):
|
||||||
self.assertResponse('https://sourceforge.net/tracker/index.php?'\
|
s = r';.*Status.*: \w+;'
|
||||||
'func=detail&aid=589953&group_id=58965&atid=489447',
|
self.assertRegexp('https://sourceforge.net/tracker/index.php?'\
|
||||||
'Bug #589953: Logger doesn\'t log QUITs.')
|
'func=detail&aid=589953&group_id=58965&atid=489447', s)
|
||||||
self.assertResponse('https://sourceforge.net/tracker/index.php?'\
|
self.assertRegexp('https://sourceforge.net/tracker/index.php?'\
|
||||||
'func=detail&aid=712761&group_id=58965&atid=489450',
|
'func=detail&aid=712761&group_id=58965&atid=489450', s)
|
||||||
'Feature Request #712761: PyPI searching and announcements')
|
self.assertRegexp('https://sourceforge.net/tracker/index.php?'\
|
||||||
self.assertResponse('https://sourceforge.net/tracker/index.php?'\
|
'func=detail&aid=540223&group_id=235&atid=300235', s)
|
||||||
'func=detail&aid=540223&group_id=235&atid=300235',
|
self.assertRegexp('https://sourceforge.net/tracker/index.php?'\
|
||||||
'Patch #540223: update_idle_times patch')
|
'func=detail&aid=561547&group_id=235&atid=200235', s)
|
||||||
self.assertResponse('https://sourceforge.net/tracker/index.php?'\
|
self.assertRegexp('http://sourceforge.net/tracker/index.php?'\
|
||||||
'func=detail&aid=561547&group_id=235&atid=200235',
|
'func=detail&aid=400942&group_id=235&atid=390395', s)
|
||||||
'Support Request #561547: connecting via proxy')
|
# test that it works without index.php
|
||||||
self.assertResponse('http://sourceforge.net/tracker/index.php?'\
|
self.assertNotError('https://sourceforge.net/tracker/?'\
|
||||||
'func=detail&aid=400942&group_id=235&atid=390395',
|
'func=detail&aid=540223&group_id=235&atid=300235')
|
||||||
'Plugin #400942: plugins/gen_away.c -- Generate new away msgs on'\
|
# test that it works with www
|
||||||
' the fly.')
|
self.assertNotError('https://www.sourceforge.net/tracker/?'\
|
||||||
|
'func=detail&aid=540223&group_id=235&atid=300235')
|
||||||
|
# test that it works with www and without index.php
|
||||||
|
self.assertNotError('https://www.sourceforge.net/tracker/index.php?'\
|
||||||
|
'func=detail&aid=540223&group_id=235&atid=300235')
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user