All plugins: Add Python 3 support.

master
Valentin Lorentz 2013-03-25 19:12:08 +01:00
parent 5f4817d40f
commit 0f19d6126d
66 changed files with 273 additions and 194 deletions

View File

@ -55,14 +55,15 @@ __contributors__ = {}
__url__ = 'http://supybot.fr.cr/AttackProtector' __url__ = 'http://supybot.fr.cr/AttackProtector'
# 'http://supybot.com/Members/yourname/AttackProtector/download' # 'http://supybot.com/Members/yourname/AttackProtector/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -71,7 +71,7 @@ class AttackProtectorDatabase:
self._collections = {} self._collections = {}
def add(self, item): def add(self, item):
if not self._collections.has_key(item.kind): if item.kind not in self._collections:
self._collections.update({item.kind: []}) self._collections.update({item.kind: []})
self._collections[item.kind].append(item) self._collections[item.kind].append(item)
self.refresh() self.refresh()
@ -122,7 +122,7 @@ class AttackProtector(callbacks.Plugin):
elif kind in ['nick']: elif kind in ['nick']:
newNick = msg.args[0] newNick = msg.args[0]
channels = [] channels = []
for (channel, c) in irc.state.channels.iteritems(): for (channel, c) in irc.state.channels.items():
if newNick in c.users: if newNick in c.users:
channels.append(channel) channels.append(channel)
prefix = '*!' + msg.prefix.split('!')[1] prefix = '*!' + msg.prefix.split('!')[1]

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Biography/download' __url__ = '' # 'http://supybot.com/Members/yourname/Biography/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Brainfuck/download' __url__ = '' # 'http://supybot.com/Members/yourname/Brainfuck/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Coffee/download' __url__ = '' # 'http://supybot.com/Members/yourname/Coffee/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Darkfallonline/download' __url__ = '' # 'http://supybot.com/Members/yourname/Darkfallonline/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -54,14 +54,15 @@ __contributors__ = {supybot.authors.progval: ['fix issues with new version of '
__url__ = "" __url__ = ""
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -76,7 +76,7 @@ class Debian(callbacks.Plugin):
responses = [] responses = []
if '*' in filename: if '*' in filename:
irc.error('Wildcard characters can not be specified.', Raise=True) irc.error('Wildcard characters can not be specified.', Raise=True)
args['keywords'] = urllib.quote(filename, '') args['keywords'] = utils.web.urlquote(filename, '')
url %= args url %= args
try: try:
html = utils.web.getUrl(url).decode() html = utils.web.getUrl(url).decode()
@ -365,7 +365,7 @@ class Debian(callbacks.Plugin):
if "There is no record of Bug" in text: if "There is no record of Bug" in text:
irc.error('I could not find a bug report matching that number.', irc.error('I could not find a bug report matching that number.',
Raise=True) Raise=True)
searches = map(lambda p: p.search(text), self._searches) searches = list(map(lambda p: p.search(text), self._searches))
sev = self._severity.search(text) sev = self._severity.search(text)
tags = self._tags.search(text) tags = self._tags.search(text)
# This section should be cleaned up to ease future modifications # This section should be cleaned up to ease future modifications

View File

@ -53,14 +53,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = 'http://supybot.fr.cr/ERepublik' __url__ = 'http://supybot.fr.cr/ERepublik'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Eureka/download' __url__ = '' # 'http://supybot.com/Members/yourname/Eureka/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -233,7 +233,7 @@ class Eureka(callbacks.Plugin):
if channel not in self.states: if channel not in self.states:
irc.error(_('Eureka is not enabled on this channel')) irc.error(_('Eureka is not enabled on this channel'))
return return
scores = self.states[channel].scores.items() scores = list(self.states[channel].scores.items())
if scores == []: if scores == []:
irc.reply(_('Noone played yet.')) irc.reply(_('Noone played yet.'))
else: else:

View File

@ -56,7 +56,7 @@ class EurekaTestCase(ChannelPluginTestCase):
# Avoid conflicts between tests. # Avoid conflicts between tests.
# We use .keys() in order to prevent this error: # We use .keys() in order to prevent this error:
# RuntimeError: dictionary changed size during iteration # RuntimeError: dictionary changed size during iteration
for name in schedule.schedule.events.keys(): for name in list(schedule.schedule.events.keys()):
schedule.removeEvent(name) schedule.removeEvent(name)
self.prefix1 = 'test!user@host.domain.tld' self.prefix1 = 'test!user@host.domain.tld'
self.prefix2 = 'foo!bar@baz' self.prefix2 = 'foo!bar@baz'

View File

@ -53,14 +53,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/GUI/download' __url__ = '' # 'http://supybot.com/Members/yourname/GUI/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -47,14 +47,15 @@ __contributors__ = {
supybot.authors.skorobeus: ['geekquote snarfer', 'qdb'], supybot.authors.skorobeus: ['geekquote snarfer', 'qdb'],
} }
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -62,7 +62,7 @@ class GeekQuote(callbacks.PluginRegexp):
def callCommand(self, method, irc, msg, *L, **kwargs): def callCommand(self, method, irc, msg, *L, **kwargs):
try: try:
self.__parent.callCommand(method, irc, msg, *L, **kwargs) self.__parent.callCommand(method, irc, msg, *L, **kwargs)
except utils.web.Error, e: except utils.web.Error as e:
irc.error(str(e)) irc.error(str(e))
_joiner = ' // ' _joiner = ' // '
@ -120,7 +120,7 @@ class GeekQuote(callbacks.PluginRegexp):
url = 'http://%s/' % site url = 'http://%s/' % site
try: try:
html = utils.web.getUrl(url) html = utils.web.getUrl(url)
except utils.web.Error, e: except utils.web.Error as e:
self.log.info('%u server returned the error: %s', self.log.info('%u server returned the error: %s',
site, utils.web.strError(e)) site, utils.web.strError(e))
last = re.search(r'<li class="last"><a href="(\d+)">', html) last = re.search(r'<li class="last"><a href="(\d+)">', html)
@ -133,7 +133,7 @@ class GeekQuote(callbacks.PluginRegexp):
html = '' html = ''
try: try:
html = utils.web.getUrl(url) html = utils.web.getUrl(url)
except utils.web.Error, e: except utils.web.Error as e:
self.log.info('%u server returned the error: %s', self.log.info('%u server returned the error: %s',
site, utils.web.strError(e)) site, utils.web.strError(e))
s = None s = None

View File

@ -53,14 +53,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/GitHub/download' __url__ = '' # 'http://supybot.com/Members/yourname/GitHub/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -28,23 +28,27 @@
### ###
import sys
import json import json
import time import time
import ur1ca
import urllib import urllib
import socket import socket
import threading import threading
import SocketServer
import supybot.log as log import supybot.log as log
import supybot.utils as utils import supybot.utils as utils
import supybot.world as world import supybot.world as world
from cStringIO import StringIO
from supybot.commands import * from supybot.commands import *
import supybot.plugins as plugins import supybot.plugins as plugins
import supybot.ircmsgs as ircmsgs import supybot.ircmsgs as ircmsgs
import supybot.ircutils as ircutils import supybot.ircutils as ircutils
import supybot.callbacks as callbacks import supybot.callbacks as callbacks
import supybot.httpserver as httpserver import supybot.httpserver as httpserver
from . import ur1ca
if sys.version_info[0] < 3:
from cStringIO import StringIO
else:
from io import StringIO
try: try:
from supybot.i18n import PluginInternationalization from supybot.i18n import PluginInternationalization
from supybot.i18n import internationalizeDocstring from supybot.i18n import internationalizeDocstring

View File

@ -25,9 +25,12 @@ RETURN STATUS:
import sys import sys
import urllib import urllib
import urlparse
import re import re
if sys.version_info[0] < 3:
import urlparse
else:
import urllib.parse as urlparse
UR1CA = "http://ur1.ca/" UR1CA = "http://ur1.ca/"
ESUCCESS = 0 ESUCCESS = 0
@ -136,10 +139,10 @@ def __do_main():
status, msg = scrape(doc) status, msg = scrape(doc)
if status: if status:
print msg print(msg)
sys.exit(ESUCCESS) sys.exit(ESUCCESS)
else: else:
print >> sys.stderr, msg sys.stderr.write(msg + '\n')
sys.exit(EFAIL) sys.exit(EFAIL)

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Glob2Chan/download' __url__ = '' # 'http://supybot.com/Members/yourname/Glob2Chan/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -53,14 +53,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/GoodFrench/download' __url__ = '' # 'http://supybot.com/Members/yourname/GoodFrench/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/I18nPlaceholder/download' __url__ = '' # 'http://supybot.com/Members/yourname/I18nPlaceholder/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -33,7 +33,7 @@ import sys
import supybot.conf as conf import supybot.conf as conf
import supybot.registry as registry import supybot.registry as registry
from plugin import Placeholder from .plugin import Placeholder as Placeholder
if 'supybot.i18n' not in sys.modules: if 'supybot.i18n' not in sys.modules:
sys.modules['supybot.i18n'] = Placeholder() sys.modules['supybot.i18n'] = Placeholder()

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Iwant/download' __url__ = '' # 'http://supybot.com/Members/yourname/Iwant/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -112,7 +112,7 @@ class Iwant(callbacks.Plugin):
irc.error(_('No wish for the moment.')) irc.error(_('No wish for the moment.'))
return return
indexes = range(1, len(wishlist) + 1) indexes = range(1, len(wishlist) + 1)
wishlist_with_index = zip(indexes, wishlist) wishlist_with_index = list(zip(indexes, wishlist))
wish = random.sample(wishlist_with_index, 1)[0] wish = random.sample(wishlist_with_index, 1)[0]
irc.reply(_('Wish #%i is %s.') % wish) irc.reply(_('Wish #%i is %s.') % wish)
random = wrap(random, ['channel']) random = wrap(random, ['channel'])

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Kickme/download' __url__ = '' # 'http://supybot.com/Members/yourname/Kickme/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/LimnoriaChan/download' __url__ = '' # 'http://supybot.com/Members/yourname/LimnoriaChan/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -53,14 +53,15 @@ __contributors__ = {supybot.authors.progval: ['enhance configurability',
__url__ = "" __url__ = ""
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/ListEmpty/download' __url__ = '' # 'http://supybot.com/Members/yourname/ListEmpty/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Listener/download' __url__ = '' # 'http://supybot.com/Members/yourname/Listener/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/MeditationExcuses/download' __url__ = '' # 'http://supybot.com/Members/yourname/MeditationExcuses/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -51,14 +51,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/MegaHAL/download' __url__ = '' # 'http://supybot.com/Members/yourname/MegaHAL/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -34,19 +34,23 @@ import sys
import random import random
import supybot.conf as conf import supybot.conf as conf
import supybot.utils as utils import supybot.utils as utils
from cStringIO import StringIO
from supybot.commands import * from supybot.commands import *
import supybot.plugins as plugins import supybot.plugins as plugins
import supybot.ircutils as ircutils import supybot.ircutils as ircutils
import supybot.callbacks as callbacks import supybot.callbacks as callbacks
if sys.version_info[0] < 3:
from cStringIO import StringIO
else:
from io import StringIO
try: try:
import mh_python as megahal import mh_python as megahal
except ImportError: except ImportError:
raise callbacks.Error, 'You need to have MegaHAL installed to use this ' \ raise callbacks.Error('You need to have MegaHAL installed to use this '
'plugin. Download it at ' \ 'plugin. Download it at '
'<http://megahal.alioth.debian.org/>' \ '<http://megahal.alioth.debian.org/>'
'or with <apt-get install megahal>' 'or with <apt-get install megahal>')
try: try:
from supybot.i18n import PluginInternationalization from supybot.i18n import PluginInternationalization
@ -133,7 +137,6 @@ class MegaHAL(callbacks.Plugin):
message = parsed.group('message') message = parsed.group('message')
usedToStartWithNick = True usedToStartWithNick = True
if self.registryValue('answer.commands') or usedToStartWithNick: if self.registryValue('answer.commands') or usedToStartWithNick:
print msg.args[0]
self._response(message, self._response(message,
self.registryValue('answer.probabilityWhenAddressed', self.registryValue('answer.probabilityWhenAddressed',
msg.args[0]), msg.args[0]),

View File

@ -53,14 +53,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/MilleBornes/download' __url__ = '' # 'http://supybot.com/Members/yourname/MilleBornes/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -53,14 +53,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/NoLatin1/download' __url__ = '' # 'http://supybot.com/Members/yourname/NoLatin1/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Pinglist/download' __url__ = '' # 'http://supybot.com/Members/yourname/Pinglist/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Redmine/download' __url__ = '' # 'http://supybot.com/Members/yourname/Redmine/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -55,9 +55,12 @@ class AccessDenied(Exception):
def fetch(site, uri, **kwargs): def fetch(site, uri, **kwargs):
url = site['url'] + uri + '.json' url = site['url'] + uri + '.json'
if kwargs: if kwargs:
url += '?' + utils.web.urlencode(kwargs) url += '?' + utils.web.urlencode(kwargs).decode()
try: try:
return json.load(utils.web.getUrlFd(url)) data = utils.web.getUrl(url)
if sys.version_info[0] >= 3:
data = data.decode('utf8')
return json.loads(data)
except utils.web.Error: except utils.web.Error:
raise ResourceNotFound() raise ResourceNotFound()
@ -76,10 +79,11 @@ def flatten_subdicts(dicts):
def get_project(site, project): def get_project(site, project):
projects = [] projects = []
for variable in ('id', 'identifier', 'name'): for variable in ('id', 'identifier', 'name'):
projects = filter(lambda x:x[variable] == project, projects = list(filter(lambda x:x[variable] == project,
fetch(site, 'projects')['projects']) fetch(site, 'projects')['projects']))
if projects: if projects:
break break
projects = list(projects)
if not projects: if not projects:
raise ResourceNotFound() raise ResourceNotFound()
elif len(projects) > 1: elif len(projects) > 1:
@ -206,11 +210,16 @@ class Redmine(callbacks.Plugin):
irc.error(_('Invalid site name.'), Raise=True) irc.error(_('Invalid site name.'), Raise=True)
if name in self.conf.sites(): if name in self.conf.sites():
irc.error(_('This site name is already registered.'), Raise=True) irc.error(_('This site name is already registered.'), Raise=True)
try: data = utils.web.getUrl(url + 'projects.json')
data = json.load(utils.web.getUrlFd(url + 'projects.json')) if sys.version_info[0] >= 3:
data = data.decode('utf8')
data = json.loads(data)
assert 'total_count' in data assert 'total_count' in data
except: #try:
irc.error(_('This is not a valid Redmine site.'), Raise=True) # data = json.load(utils.web.getUrlFd(url + 'projects.json'))
# assert 'total_count' in data
#except:
# irc.error(_('This is not a valid Redmine site.'), Raise=True)
with self.conf.sites.editable() as sites: with self.conf.sites.editable() as sites:
sites[name] = {'url': url} sites[name] = {'url': url}
irc.replySuccess() irc.replySuccess()
@ -235,7 +244,7 @@ class Redmine(callbacks.Plugin):
Return the list of known redmine sites.""" Return the list of known redmine sites."""
sites = self.conf.sites().keys() sites = self.conf.sites().keys()
if sites: if sites:
irc.reply(format('%L', sites)) irc.reply(format('%L', list(sites)))
else: else:
irc.reply(_('No registered Redmine site.')) irc.reply(_('No registered Redmine site.'))
list = wrap(list, []) list = wrap(list, [])

View File

@ -52,14 +52,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Scheme/download' __url__ = '' # 'http://supybot.com/Members/yourname/Scheme/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -152,11 +152,11 @@ DEFAULT_ENV = [
('set!', scm_set), ('set!', scm_set),
] ]
# Add some math operators # Add some math operators
DEFAULT_ENV += map(lambda (x,y):(x, schemify_math(y)), ( DEFAULT_ENV += map(lambda x:(x[0], schemify_math(x[1])), (
('+', operator.add), ('+', operator.add),
('-', operator.sub), ('-', operator.sub),
('*', operator.mul), ('*', operator.mul),
('/', operator.div), ('/', operator.truediv),
)) ))
DEFAULT_ENV = dict(DEFAULT_ENV) DEFAULT_ENV = dict(DEFAULT_ENV)
@ -216,7 +216,7 @@ def eval_scheme(tree, env=DEFAULT_ENV):
if tree in env: if tree in env:
return env[tree] return env[tree]
else: else:
print repr(env) print(repr(env))
raise SchemeException(_('Undefined keyword %s.') % tree) raise SchemeException(_('Undefined keyword %s.') % tree)
first = eval_scheme(tree[0]) first = eval_scheme(tree[0])
if callable(first): if callable(first):

View File

@ -55,14 +55,15 @@ __contributors__ = {supybot.authors.progval: ['code enhancements',
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Seeks/download' __url__ = '' # 'http://supybot.com/Members/yourname/Seeks/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -53,14 +53,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Sudo/download' __url__ = '' # 'http://supybot.com/Members/yourname/Sudo/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -54,14 +54,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/SupyML/download' __url__ = '' # 'http://supybot.com/Members/yourname/SupyML/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -29,9 +29,9 @@
### ###
import re import re
import sys
import copy import copy
import time import time
import Queue
import supybot.conf as conf import supybot.conf as conf
from xml.dom import minidom from xml.dom import minidom
import supybot.world as world import supybot.world as world

View File

@ -54,14 +54,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = 'http://supybot.fr.cr/SupySandbox' __url__ = 'http://supybot.fr.cr/SupySandbox'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -41,8 +41,8 @@ EVAL_MAXMEMORYBYTES = 75 * 1024 * 1024 # 10 MiB
try: try:
import sandbox as S import sandbox as S
except ImportError: except ImportError:
print 'You need pysandbox in order to run SupySandbox plugin ' + \ print('You need pysandbox in order to run SupySandbox plugin '
'[http://github.com/haypo/pysandbox].' '[http://github.com/haypo/pysandbox].')
raise raise
import re import re
import os import os
@ -106,10 +106,10 @@ def evalPython(line, locals=None):
sandbox.execute( sandbox.execute(
evalPythonInSandbox, evalPythonInSandbox,
locals={'namespace': locals, 'line': line}) locals={'namespace': locals, 'line': line})
except BaseException, e: except BaseException as e:
print 'Error: [%s] %s' % (e.__class__.__name__, str(e)) print('Error: [%s] %s' % (e.__class__.__name__, str(e)))
except: except:
print 'Error: <unknown exception>' print('Error: <unknown exception>')
sys.stdout.flush() sys.stdout.flush()
@contextlib.contextmanager @contextlib.contextmanager
@ -162,7 +162,7 @@ class SupySandbox(callbacks.Plugin):
Runs Python code safely thanks to pysandbox""" Runs Python code safely thanks to pysandbox"""
try: try:
irc.reply(handle_line(code.replace(' $$ ', '\n'))) irc.reply(handle_line(code.replace(' $$ ', '\n')))
except SandboxError, e: except SandboxError as e:
irc.error('; '.join(e.args)) irc.error('; '.join(e.args))
sandbox = wrap(sandbox, ['text']) sandbox = wrap(sandbox, ['text'])

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/TWSS/download' __url__ = '' # 'http://supybot.com/Members/yourname/TWSS/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -53,14 +53,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = 'http://supybot.fr.cr/Trigger' __url__ = 'http://supybot.fr.cr/Trigger'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -73,7 +73,7 @@ class Trigger(callbacks.Plugin):
try: try:
msg.args = (channel,) + msg.args[1:] msg.args = (channel,) + msg.args[1:]
self.Proxy(irc.irc, msg, tokens) self.Proxy(irc.irc, msg, tokens)
except Exception, e: except Exception as e:
self.log.exception('Error occured while running triggered command:') self.log.exception('Error occured while running triggered command:')
def doJoin(self, irc, msg): def doJoin(self, irc, msg):
self._run(irc, msg, 'join') self._run(irc, msg, 'join')

View File

@ -54,14 +54,15 @@ if not hasattr(supybot.authors, 'progval'):
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Trivia/download' __url__ = '' # 'http://supybot.com/Members/yourname/Trivia/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -53,14 +53,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Twitter/download' __url__ = '' # 'http://supybot.com/Members/yourname/Twitter/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -30,15 +30,12 @@
from __future__ import division from __future__ import division
import config
import htmlentitydefs
reload(config)
import re import re
import sys import sys
import time import time
import json
import threading import threading
import simplejson
import supybot.log as log import supybot.log as log
import supybot.conf as conf import supybot.conf as conf
import supybot.utils as utils import supybot.utils as utils
@ -49,6 +46,11 @@ import supybot.plugins as plugins
import supybot.ircutils as ircutils import supybot.ircutils as ircutils
import supybot.registry as registry import supybot.registry as registry
import supybot.callbacks as callbacks import supybot.callbacks as callbacks
if sys.version_info[0] < 3:
import htmlentitydefs
else:
import html.entities as htmlentitydefs
from imp import reload
try: try:
from supybot.i18n import PluginInternationalization from supybot.i18n import PluginInternationalization
from supybot.i18n import internationalizeDocstring from supybot.i18n import internationalizeDocstring
@ -62,9 +64,10 @@ except:
try: try:
import twitter import twitter
except ImportError: except ImportError:
raise callbacks.Error, 'You need the python-twitter library.' raise callbacks.Error('You need the python-twitter library.')
reload(twitter) reload(twitter)
if twitter.__version__.split('.') < ['0', '8', '0']: if not hasattr(twitter, '__version__') or \
twitter.__version__.split('.') < ['0', '8', '0']:
raise ImportError('You current version of python-twitter is to old, ' raise ImportError('You current version of python-twitter is to old, '
'you need at least version 0.8.0, because older ' 'you need at least version 0.8.0, because older '
'versions do not support OAuth authentication.') 'versions do not support OAuth authentication.')
@ -93,11 +96,11 @@ class ExtendedApi(twitter.Api):
raise TwitterError("'id' must be an integer") raise TwitterError("'id' must be an integer")
url = 'http://api.twitter.com/1/statuses/retweet/%s.json' % id url = 'http://api.twitter.com/1/statuses/retweet/%s.json' % id
json = self._FetchUrl(url, post_data={'dummy': None}) json = self._FetchUrl(url, post_data={'dummy': None})
data = simplejson.loads(json) data = json.loads(json)
self._CheckForTwitterError(data) self._CheckForTwitterError(data)
return twitter.Status.NewFromJsonDict(data) return twitter.Status.NewFromJsonDict(data)
_tco_link_re = re.compile(u'http://t.co/[a-zA-Z0-9]+') _tco_link_re = re.compile('http://t.co/[a-zA-Z0-9]+')
def expandLinks(tweet): def expandLinks(tweet):
if 'Untiny.plugin' in sys.modules: if 'Untiny.plugin' in sys.modules:
def repl(link): def repl(link):

View File

@ -30,7 +30,7 @@
from supybot.test import * from supybot.test import *
import plugin from . import plugin
class TwitterTestCase(ChannelPluginTestCase): class TwitterTestCase(ChannelPluginTestCase):
plugins = ('Twitter', 'Untiny') plugins = ('Twitter', 'Untiny')

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/TwitterStream/download' __url__ = '' # 'http://supybot.com/Members/yourname/TwitterStream/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Untiny/download' __url__ = '' # 'http://supybot.com/Members/yourname/Untiny/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -53,14 +53,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Variables/download' __url__ = '' # 'http://supybot.com/Members/yourname/Variables/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/WebLogs/download' __url__ = '' # 'http://supybot.com/Members/yourname/WebLogs/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -224,7 +224,7 @@ class WebLogsServerCallback(httpserver.SupyHTTPServerCallback):
page_body = """Here is a list of available logs:<ul>""" page_body = """Here is a list of available logs:<ul>"""
for channel in WebLogsMiddleware.get_channel_list(): for channel in WebLogsMiddleware.get_channel_list():
page_body += '<li><a href="./html/%s/">%s</a></li>' % ( page_body += '<li><a href="./html/%s/">%s</a></li>' % (
urllib.quote(channel), channel) utils.web.urlquote(channel), channel)
page_body += '</ul>' page_body += '</ul>'
self.wfile.write(page_template % self.wfile.write(page_template %
{'title': 'Index', 'body': page_body}) {'title': 'Index', 'body': page_body})
@ -238,7 +238,7 @@ class WebLogsServerCallback(httpserver.SupyHTTPServerCallback):
self.wfile.write('Bad URL.') self.wfile.write('Bad URL.')
return return
assert mode in ('html', 'json') assert mode in ('html', 'json')
channel = urllib.unquote(channel) channel = utils.web.urlunquote(channel)
if channel not in WebLogsMiddleware.get_channel_list(): if channel not in WebLogsMiddleware.get_channel_list():
self.send_response(404) self.send_response(404)
self.send_header('Content-type', 'text/plain') self.send_header('Content-type', 'text/plain')

View File

@ -53,14 +53,15 @@ __contributors__ = {}
__url__ = 'http://supybot.fr.cr/WebStats' __url__ = 'http://supybot.fr.cr/WebStats'
# 'http://supybot.com/Members/yourname/WebStats/download' # 'http://supybot.com/Members/yourname/WebStats/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -74,9 +74,9 @@ world.webStatsCacheLinks = {}
testing = world.testing testing = world.testing
def getTemplate(name): def getTemplate(name):
if sys.modules.has_key('WebStats.templates.skeleton'): if 'WebStats.templates.skeleton' in sys.modules:
reload(sys.modules['WebStats.templates.skeleton']) reload(sys.modules['WebStats.templates.skeleton'])
if sys.modules.has_key('WebStats.templates.%s' % name): if 'WebStats.templates.%s' % name in sys.modules:
reload(sys.modules['WebStats.templates.%s' % name]) reload(sys.modules['WebStats.templates.%s' % name])
module = __import__('WebStats.templates.%s' % name) module = __import__('WebStats.templates.%s' % name)
return getattr(getattr(module, 'templates'), name) return getattr(getattr(module, 'templates'), name)
@ -155,7 +155,7 @@ class WebStatsServerCallback(httpserver.SupyHTTPServerCallback):
response = 404 response = 404
content_type = 'text/html' content_type = 'text/html'
output = getTemplate('error404').get(not testing) output = getTemplate('error404').get(not testing)
except FooException, e: except FooException as e:
response = 500 response = 500
content_type = 'text/html' content_type = 'text/html'
if output == '': if output == '':
@ -167,7 +167,7 @@ class WebStatsServerCallback(httpserver.SupyHTTPServerCallback):
self.send_response(response) self.send_response(response)
self.send_header('Content-type', content_type) self.send_header('Content-type', content_type)
self.end_headers() self.end_headers()
self.wfile.write(output) self.wfile.write(output.encode())
class WebStatsDB: class WebStatsDB:
def __init__(self): def __init__(self):

View File

@ -1,4 +1,4 @@
import skeleton from . import skeleton
from WebStats.plugin import _ from WebStats.plugin import _
content = """ content = """

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Website/download' __url__ = '' # 'http://supybot.com/Members/yourname/Website/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -29,8 +29,8 @@
### ###
import re import re
import sys
import json import json
import urllib
import supybot.world as world import supybot.world as world
import supybot.utils as utils import supybot.utils as utils
from supybot import httpserver from supybot import httpserver
@ -41,6 +41,11 @@ import supybot.ircutils as ircutils
import supybot.callbacks as callbacks import supybot.callbacks as callbacks
from supybot.i18n import PluginInternationalization, internationalizeDocstring from supybot.i18n import PluginInternationalization, internationalizeDocstring
if sys.version_info[0] < 3:
from urllib import urlencode
else:
from urllib.parse import urlencode
_ = PluginInternationalization('Website') _ = PluginInternationalization('Website')
class WebsiteCallback(httpserver.SupyHTTPServerCallback): class WebsiteCallback(httpserver.SupyHTTPServerCallback):
@ -59,8 +64,11 @@ class WebsiteCallback(httpserver.SupyHTTPServerCallback):
def query(path, args={}): def query(path, args={}):
args = dict([(x,y) for x,y in args.items() if y is not None]) args = dict([(x,y) for x,y in args.items() if y is not None])
url = 'http://supybot.fr.cr/api%s?%s' % (path, urllib.urlencode(args)) url = 'http://supybot.fr.cr/api%s?%s' % (path, urlencode(args))
return json.load(utils.web.getUrlFd(url)) data = utils.web.getUrl(url)
if sys.version_info[0] >= 3:
data = data.decode()
return json.loads(data)
instance = None instance = None

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/WikiTrans/download' __url__ = '' # 'http://supybot.com/Members/yourname/WikiTrans/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -29,6 +29,8 @@
### ###
from __future__ import unicode_literals
from supybot.test import * from supybot.test import *
class WikiTransTestCase(PluginTestCase): class WikiTransTestCase(PluginTestCase):
@ -41,7 +43,7 @@ class WikiTransTestCase(PluginTestCase):
self.assertResponse('translate en fr IRC bot', 'Robot IRC') self.assertResponse('translate en fr IRC bot', 'Robot IRC')
self.assertResponse('translate fr en robot IRC', 'Internet Relay Chat bot') self.assertResponse('translate fr en robot IRC', 'Internet Relay Chat bot')
self.assertResponse(u'translate fr en Chef-d\'œuvre', 'Masterpiece') self.assertResponse('translate fr en Chef-d\'œuvre', 'Masterpiece')
self.assertResponse('translate en fr Masterpiece', 'Chef-d\'œuvre') self.assertResponse('translate en fr Masterpiece', 'Chef-d\'œuvre')
self.assertResponse('translate en fr Master (Doctor Who)', self.assertResponse('translate en fr Master (Doctor Who)',

View File

@ -55,14 +55,15 @@ __contributors__ = {supybot.authors.progval: ['enhance configurability',
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Wikipedia/download' __url__ = '' # 'http://supybot.com/Members/yourname/Wikipedia/download'
import config from . import config
import plugin from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded. reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be # Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well! # reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing: if world.testing:
import test from . import test
Class = plugin.Class Class = plugin.Class
configure = config.configure configure = config.configure

View File

@ -31,9 +31,9 @@
import re import re
import sys
import string import string
import urllib import urllib
import StringIO
import lxml.html import lxml.html
from lxml import etree from lxml import etree
import supybot.utils as utils import supybot.utils as utils
@ -41,6 +41,10 @@ from supybot.commands import *
import supybot.plugins as plugins import supybot.plugins as plugins
import supybot.ircutils as ircutils import supybot.ircutils as ircutils
import supybot.callbacks as callbacks import supybot.callbacks as callbacks
if sys.version_info[0] < 3:
import StringIO
else:
from io import StringIO
try: try:
from supybot.i18n import PluginInternationalization from supybot.i18n import PluginInternationalization
from supybot.i18n import internationalizeDocstring from supybot.i18n import internationalizeDocstring