From e375094603f93a8c7087849a8221452c5054ac6a Mon Sep 17 00:00:00 2001 From: Dennis Kaarsemaker Date: Sun, 4 Feb 2007 23:10:10 +0100 Subject: [PATCH] More fixes everywhere --- Bugtracker/plugin.py | 33 ++++++++++++++++++++++++--------- Encyclopedia/plugin.py | 2 +- Mess/README.txt | 3 ++- Mess/__init__.py | 13 +++++++++++++ Mess/config.py | 14 ++++++++++++++ Mess/plugin.py | 14 ++++++++++++++ Mess/test.py | 14 ++++++++++++++ Webcal/plugin.py | 12 +++++++++++- 8 files changed, 93 insertions(+), 12 deletions(-) diff --git a/Bugtracker/plugin.py b/Bugtracker/plugin.py index 32f7dfc..a6f470e 100644 --- a/Bugtracker/plugin.py +++ b/Bugtracker/plugin.py @@ -281,6 +281,10 @@ class Bugtracker(callbacks.PluginRegexp): r"""\b(?P(([a-z0-9]+)?\s+bugs?|[a-z]+))\s+#?(?P\d+(?!\d*\.\d+)((,|\s*(and|en|et|und|ir))\s*#?\d+(?!\d*\.\d+))*)""" if msg.args[0][0] == '#' and not self.registryValue('bugSnarfer', msg.args[0]): return + nbugs = msg.tagged('nbugs') + if not nbugs: nbugs = 0 + if nbugs >= 5: + return # Don't double on commands s = str(msg).split(':')[2] @@ -293,7 +297,8 @@ class Bugtracker(callbacks.PluginRegexp): reps = ((' ',''),('#',''),('and',','),('en',','),('et',','),('und',','),('ir',',')) for r in reps: bugids = bugids.replace(r[0],r[1]) - bugids = bugids.split(',')[:5] + bugids = bugids.split(',')[:5-nbugs] + msg.tag('nbugs', nbugs + len(bugids)) bt = map(lambda x: x.lower(), match.group('bt').split()) name = '' if len(bt) == 1 and not (bt[0] in ['bug','bugs']): @@ -331,7 +336,8 @@ class Bugtracker(callbacks.PluginRegexp): try: report = self.get_bug(tracker,bugid,self.registryValue('showassignee', msg.args[0])) except BugNotFoundError: - irc.error("%s bug %d could not be found" % (tracker.description, bugid)) + if self.registryValue('replyWhenNotFound'): + irc.error("%s bug %d could not be found" % (tracker.description, bugid)) except BugtrackerError, e: if 'private' in str(e): irc.reply("Bug %d on http://launchpad.net/bugs/%d is private" % (bugid, bugid)) @@ -344,9 +350,15 @@ class Bugtracker(callbacks.PluginRegexp): irc.reply(r, prefixNick=False) def turlSnarfer(self, irc, msg, match): - r"(?Phttps?://\S*?)(show_bug.cgi\?id=|bugreport.cgi\?bug=|(bugs|\+bug)/|/ticket/|tracker/\S*aid=)(?P\d+)(?P&group_id=\d+&at_id=\d+)?" + r"(?Phttps?://\S*?)/(Bugs/0*|str.php\?L|show_bug.cgi\?id=|bugreport.cgi\?bug=|(bugs|\+bug)/|ticket/|tracker/|\S*aid=)(?P\d+)(?P&group_id=\d+&at_id=\d+)?" + print match if msg.args[0][0] == '#' and not self.registryValue('bugSnarfer', msg.args[0]): return + nbugs = msg.tagged('nbugs') + if not nbugs: nbugs = 0 + if nbugs >= 5: + return + msg.tag('nbugs', nbugs+1) try: tracker = self.get_tracker(match.group(0),match.group('sfurl')) if not tracker: @@ -665,7 +677,7 @@ class Trac(IBugtracker): severity = l[l.find('>')+1:l.find('')+1:l.find('\[.*?\]\s*(?P.*?)</h2> .*? - Assigned To.*?<br>\s+(?P<assignee>\S+) + assigned.*?<br>\s+(?P<assignee>\S+) .*? - Priority.*?(?P<priority>\d+) + priority.*?(?P<priority>\d+) .*? - Status.*?<br>\s+(?P<status>\S+) + status.*?<br>\s+(?P<status>\S+) .*? - Resolution.*?<br>\s+(?P<resolution>\S+) + resolution.*?<br>\s+(?P<resolution>\S+) .*? """, re.VERBOSE | re.DOTALL | re.I) class Sourceforge(IBugtracker): _sf_url = 'http://sf.net/support/tracker.php?aid=%d' def get_bug(self, id): url = self._sf_url % id + print url try: bugdata = utils.web.getUrl(url) except Exception, e: s = 'Could not parse data returned by %s: %s' % (self.description, e) raise BugtrackerError, s + print bugdata try: reo = sfre.search(bugdata) status = reo.group('status') @@ -754,6 +768,7 @@ class Sourceforge(IBugtracker): status += ' ' + resolution return [(id, None, reo.group('title'), "Pri: %s" % reo.group('priority'), status, reo.group('assignee'),self._sf_url % id)] except: + raise raise BugNotFoundError # Introspection is quite cool @@ -774,7 +789,7 @@ registerBugtracker('freedesktop2', 'http://bugs.freedesktop.org', 'Freedesktop', registerBugtracker('openoffice', 'http://openoffice.org/issues', 'OpenOffice.org', 'issuezilla') registerBugtracker('malone', 'https://launchpad.net/malone', 'Malone', 'malone') registerBugtracker('debian', 'http://bugs.debian.org', 'Debian', 'debbugs') -registerBugtracker('trac', 'http://projects.edgewall.com/trac/ticket', 'Trac', 'trac') +registerBugtracker('trac', 'http://trac.edgewall.org/ticket', 'Trac', 'trac') registerBugtracker('django', 'http://code.djangoproject.com/ticket', 'Django', 'trac') registerBugtracker('cups', 'http://www.cups.org/str.php', 'CUPS', 'str') registerBugtracker('gnewsense', 'http://bugs.gnewsense.org/Bugs', 'gNewSense', 'wikiforms') diff --git a/Encyclopedia/plugin.py b/Encyclopedia/plugin.py index 8f18260..740e1cb 100644 --- a/Encyclopedia/plugin.py +++ b/Encyclopedia/plugin.py @@ -113,7 +113,7 @@ class Encyclopedia(callbacks.Plugin): text = ' ' + text if '>' in text: - target = text[text.rfind('>')+1:].strip() + target = text[text.rfind('>')+1:].strip().split()[0] text = text[:text.rfind('>')].strip() retmsg = "%s wants you to know: " % nick diff --git a/Mess/README.txt b/Mess/README.txt index d60b47a..cadf43b 100644 --- a/Mess/README.txt +++ b/Mess/README.txt @@ -1 +1,2 @@ -Insert a description of your plugin here, with any notes, etc. about using it. +This is a random mess plugin that hardcodes many paths at the top of the plugin +code. You'll generally want to be careful with it or simply not use it. diff --git a/Mess/__init__.py b/Mess/__init__.py index ee00ea2..42d754a 100644 --- a/Mess/__init__.py +++ b/Mess/__init__.py @@ -1,3 +1,16 @@ +### +# Copyright (c) 2006-2007 Dennis Kaarsemaker +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of version 2 of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +### """ Random mess plugin """ diff --git a/Mess/config.py b/Mess/config.py index 77c7cd8..570f975 100644 --- a/Mess/config.py +++ b/Mess/config.py @@ -1,3 +1,17 @@ +### +# Copyright (c) 2006-2007 Dennis Kaarsemaker +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of version 2 of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +### + import supybot.conf as conf import supybot.registry as registry diff --git a/Mess/plugin.py b/Mess/plugin.py index 54aa357..04b8659 100644 --- a/Mess/plugin.py +++ b/Mess/plugin.py @@ -1,3 +1,17 @@ +### +# Copyright (c) 2006-2007 Dennis Kaarsemaker +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of version 2 of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +### + import supybot.utils as utils from supybot.commands import * import supybot.plugins as plugins diff --git a/Mess/test.py b/Mess/test.py index 3ae8a5f..5ae7081 100644 --- a/Mess/test.py +++ b/Mess/test.py @@ -1,3 +1,17 @@ +### +# Copyright (c) 2006-2007 Dennis Kaarsemaker +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of version 2 of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +### + from supybot.test import * class MessTestCase(PluginTestCase): diff --git a/Webcal/plugin.py b/Webcal/plugin.py index 523ef0c..f695632 100644 --- a/Webcal/plugin.py +++ b/Webcal/plugin.py @@ -1,5 +1,5 @@ ### -# Copyright (c) 2005,2006 Dennis Kaarsemaker +# Copyright (c) 2005-2007 Dennis Kaarsemaker # # This program is free software; you can redistribute it and/or modify # it under the terms of version 2 of the GNU General Public License as @@ -162,6 +162,16 @@ class Webcal(callbacks.Plugin): if tz[pos+1:] == ud: return True pos = tz.find('/',pos+1) + # Repeat, with spaces replaced by underscores + ud = ud.replace(' ','_') + if tz == ud: + return True + pos = tz.find('/') + while not (pos == -1): + if tz[pos+1:] == ud: + return True + pos = tz.find('/',pos+1) + return False def schedule(self, irc, msg, args, tz):