mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 11:09:23 +01:00
Added Sourceforge.fight
This commit is contained in:
parent
336fabe61f
commit
86451cc8ae
@ -118,7 +118,7 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
_statusOpt = {'any':100, 'open':1, 'closed':2, 'deleted':3, 'pending':4}
|
_statusOpt = {'any':100, 'open':1, 'closed':2, 'deleted':3, 'pending':4}
|
||||||
|
|
||||||
_projectURL = 'http://sourceforge.net/projects/'
|
_projectURL = 'http://sourceforge.net/projects/'
|
||||||
_trackerURL = 'https://sourceforge.net/support/tracker.php?aid='
|
_trackerURL = 'http://sourceforge.net/support/tracker.php?aid='
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
callbacks.PrivmsgCommandAndRegexp.__init__(self)
|
callbacks.PrivmsgCommandAndRegexp.__init__(self)
|
||||||
self.__class__.sf = self.__class__.sourceforge
|
self.__class__.sf = self.__class__.sourceforge
|
||||||
@ -242,9 +242,27 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
return
|
return
|
||||||
irc.reply(self._getTrackerList(url))
|
irc.reply(self._getTrackerList(url))
|
||||||
|
|
||||||
|
_totbugs = re.compile(r'Bugs</a>\s+?\( <b>([^<]+)</b>', re.S | re.I)
|
||||||
|
def _getNumBugs(self, project):
|
||||||
|
text = webutils.getUrl('%s%s' % (self._projectURL, project))
|
||||||
|
m = self._totbugs.search(text)
|
||||||
|
if m:
|
||||||
|
return m.group(1)
|
||||||
|
else:
|
||||||
|
return ''
|
||||||
|
|
||||||
|
_totrfes = re.compile(r'Feature Requests</a>\s+?\( <b>([^<]+)</b>',
|
||||||
|
re.S | re.I)
|
||||||
|
def _getNumRfes(self, project):
|
||||||
|
text = webutils.getUrl('%s%s' % (self._projectURL, project))
|
||||||
|
m = self._totrfes.search(text)
|
||||||
|
if m:
|
||||||
|
return m.group(1)
|
||||||
|
else:
|
||||||
|
return ''
|
||||||
|
|
||||||
# TODO: consolidate total* into one command which takes options for all
|
# TODO: consolidate total* into one command which takes options for all
|
||||||
# the viable statistics that can be snarfed from the project page
|
# the viable statistics that can be snarfed from the project page
|
||||||
_totbugs = re.compile(r'Bugs</a>\s+?\( <b>([^<]+)</b>', re.S | re.I)
|
|
||||||
def totalbugs(self, irc, msg, args):
|
def totalbugs(self, irc, msg, args):
|
||||||
"""[<project>]
|
"""[<project>]
|
||||||
|
|
||||||
@ -255,13 +273,28 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
project = project or self.registryValue('defaultProject', msg.args[0])
|
project = project or self.registryValue('defaultProject', msg.args[0])
|
||||||
if not project:
|
if not project:
|
||||||
raise callbacks.ArgumentError
|
raise callbacks.ArgumentError
|
||||||
text = webutils.getUrl(''.join([self._projectURL, project]))
|
total = self._getNumBugs(project)
|
||||||
m = self._totbugs.search(text)
|
if total:
|
||||||
if m:
|
irc.reply(total)
|
||||||
irc.reply(m.group(1))
|
|
||||||
else:
|
else:
|
||||||
irc.error('Could not find bug statistics.')
|
irc.error('Could not find bug statistics.')
|
||||||
|
|
||||||
|
def totalrfes(self, irc, msg, args):
|
||||||
|
"""[<project>]
|
||||||
|
|
||||||
|
Returns a count of the open/total RFEs. <project> is not needed if a
|
||||||
|
default project is set.
|
||||||
|
"""
|
||||||
|
project = privmsgs.getArgs(args, required=0, optional=1)
|
||||||
|
project = project or self.registryValue('defaultProject', msg.args[0])
|
||||||
|
if not project:
|
||||||
|
raise callbacks.ArgumentError
|
||||||
|
total = self._getNumRfes(project)
|
||||||
|
if total:
|
||||||
|
irc.reply(total)
|
||||||
|
else:
|
||||||
|
irc.error('Could not find RFE statistics.')
|
||||||
|
|
||||||
_rfeLink = re.compile(r'"([^"]+)">RFE')
|
_rfeLink = re.compile(r'"([^"]+)">RFE')
|
||||||
def rfes(self, irc, msg, args):
|
def rfes(self, irc, msg, args):
|
||||||
"""[--{any,open,closed,deleted,pending}] [<project>]
|
"""[--{any,open,closed,deleted,pending}] [<project>]
|
||||||
@ -296,24 +329,34 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
return
|
return
|
||||||
irc.reply(self._getTrackerList(url))
|
irc.reply(self._getTrackerList(url))
|
||||||
|
|
||||||
_totrfes = re.compile(r'Feature Requests</a>\s+?\( <b>([^<]+)</b>',
|
def fight(self, irc, msg, args):
|
||||||
re.S | re.I)
|
"""[--{bugs,rfes}] [--{open,closed}] <project name> <project name>
|
||||||
def totalrfes(self, irc, msg, args):
|
|
||||||
"""[<project>]
|
|
||||||
|
|
||||||
Returns a count of the open/total RFEs. <project> is not needed if a
|
Returns the projects, in order, from greatest number of bugs to least.
|
||||||
default project is set.
|
Defaults to bugs and open.
|
||||||
"""
|
"""
|
||||||
project = privmsgs.getArgs(args, required=0, optional=1)
|
search = self._getNumBugs
|
||||||
project = project or self.registryValue('defaultProject', msg.args[0])
|
type = 0
|
||||||
if not project:
|
(optlist, rest) = getopt.getopt(args, '',
|
||||||
raise callbacks.ArgumentError
|
['bugs', 'rfes', 'open', 'closed'])
|
||||||
text = webutils.getUrl(''.join([self._projectURL, project]))
|
for (option, _) in optlist:
|
||||||
m = self._totrfes.search(text)
|
if option == '--bugs':
|
||||||
if m:
|
search = self._getNumBugs
|
||||||
irc.reply(m.group(1))
|
if option == '--rfes':
|
||||||
else:
|
search = self._getNumRfes
|
||||||
irc.error('Could not find RFE statistics.')
|
if option == '--open':
|
||||||
|
type = 0
|
||||||
|
if option == '--closed':
|
||||||
|
type = 1
|
||||||
|
results = []
|
||||||
|
for proj in args:
|
||||||
|
num = search(proj)
|
||||||
|
if num:
|
||||||
|
results.append((int(num.split('/')[type].split()[0]), proj))
|
||||||
|
results.sort()
|
||||||
|
results.reverse()
|
||||||
|
s = ', '.join(['\'%s\': %s' % (s, i) for (i, s) in results])
|
||||||
|
irc.reply(s)
|
||||||
|
|
||||||
def sfSnarfer(self, irc, msg, match):
|
def sfSnarfer(self, irc, msg, match):
|
||||||
r"https?://(?:www\.)?(?:sourceforge|sf)\.net/tracker/" \
|
r"https?://(?:www\.)?(?:sourceforge|sf)\.net/tracker/" \
|
||||||
|
@ -176,4 +176,17 @@ if network:
|
|||||||
self.assertError('totalbugs lkjfad')
|
self.assertError('totalbugs lkjfad')
|
||||||
self.assertError('totalrfes lkjfad')
|
self.assertError('totalrfes lkjfad')
|
||||||
|
|
||||||
|
def testFight(self):
|
||||||
|
self.assertRegexp('fight gaim opengaim',
|
||||||
|
r'\'(open|)gaim\': \d+, \'(open|)gaim\': \d+')
|
||||||
|
self.assertRegexp('fight --rfes gaim opengaim',
|
||||||
|
r'\'(open|)gaim\': \d+, \'(open|)gaim\': \d+')
|
||||||
|
self.assertRegexp('fight --closed gaim opengaim',
|
||||||
|
r'\'(open|)gaim\': \d+, \'(open|)gaim\': \d+')
|
||||||
|
m = self.getMsg('fight --bugs gaim opengaim')
|
||||||
|
n = self.getMsg('fight --open gaim opengaim')
|
||||||
|
o = self.getMsg('fight gaim opengaim')
|
||||||
|
self.assertEqual(m, o)
|
||||||
|
self.assertEqual(n, o)
|
||||||
|
|
||||||
# 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