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'
# 'http://supybot.com/Members/yourname/AttackProtector/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -71,7 +71,7 @@ class AttackProtectorDatabase:
self._collections = {}
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[item.kind].append(item)
self.refresh()
@ -122,7 +122,7 @@ class AttackProtector(callbacks.Plugin):
elif kind in ['nick']:
newNick = msg.args[0]
channels = []
for (channel, c) in irc.state.channels.iteritems():
for (channel, c) in irc.state.channels.items():
if newNick in c.users:
channels.append(channel)
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.
__url__ = '' # 'http://supybot.com/Members/yourname/Biography/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Brainfuck/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Coffee/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Darkfallonline/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -54,14 +54,15 @@ __contributors__ = {supybot.authors.progval: ['fix issues with new version of '
__url__ = ""
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -76,7 +76,7 @@ class Debian(callbacks.Plugin):
responses = []
if '*' in filename:
irc.error('Wildcard characters can not be specified.', Raise=True)
args['keywords'] = urllib.quote(filename, '')
args['keywords'] = utils.web.urlquote(filename, '')
url %= args
try:
html = utils.web.getUrl(url).decode()
@ -365,7 +365,7 @@ class Debian(callbacks.Plugin):
if "There is no record of Bug" in text:
irc.error('I could not find a bug report matching that number.',
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)
tags = self._tags.search(text)
# 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.
__url__ = 'http://supybot.fr.cr/ERepublik'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Eureka/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

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

View File

@ -56,7 +56,7 @@ class EurekaTestCase(ChannelPluginTestCase):
# Avoid conflicts between tests.
# We use .keys() in order to prevent this error:
# RuntimeError: dictionary changed size during iteration
for name in schedule.schedule.events.keys():
for name in list(schedule.schedule.events.keys()):
schedule.removeEvent(name)
self.prefix1 = 'test!user@host.domain.tld'
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.
__url__ = '' # 'http://supybot.com/Members/yourname/GUI/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -47,14 +47,15 @@ __contributors__ = {
supybot.authors.skorobeus: ['geekquote snarfer', 'qdb'],
}
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

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

View File

@ -53,14 +53,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/GitHub/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

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

View File

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

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Glob2Chan/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -53,14 +53,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/GoodFrench/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/I18nPlaceholder/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -33,7 +33,7 @@ import sys
import supybot.conf as conf
import supybot.registry as registry
from plugin import Placeholder
from .plugin import Placeholder as Placeholder
if 'supybot.i18n' not in sys.modules:
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.
__url__ = '' # 'http://supybot.com/Members/yourname/Iwant/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -112,7 +112,7 @@ class Iwant(callbacks.Plugin):
irc.error(_('No wish for the moment.'))
return
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]
irc.reply(_('Wish #%i is %s.') % wish)
random = wrap(random, ['channel'])

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Kickme/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/LimnoriaChan/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -53,14 +53,15 @@ __contributors__ = {supybot.authors.progval: ['enhance configurability',
__url__ = ""
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/ListEmpty/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Listener/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/MeditationExcuses/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -51,14 +51,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/MegaHAL/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

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

View File

@ -53,14 +53,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/MilleBornes/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -53,14 +53,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/NoLatin1/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Pinglist/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Redmine/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

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

View File

@ -52,14 +52,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Scheme/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -152,11 +152,11 @@ DEFAULT_ENV = [
('set!', scm_set),
]
# 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.sub),
('*', operator.mul),
('/', operator.div),
('/', operator.truediv),
))
DEFAULT_ENV = dict(DEFAULT_ENV)
@ -216,7 +216,7 @@ def eval_scheme(tree, env=DEFAULT_ENV):
if tree in env:
return env[tree]
else:
print repr(env)
print(repr(env))
raise SchemeException(_('Undefined keyword %s.') % tree)
first = eval_scheme(tree[0])
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.
__url__ = '' # 'http://supybot.com/Members/yourname/Seeks/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -53,14 +53,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Sudo/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -54,14 +54,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/SupyML/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -29,9 +29,9 @@
###
import re
import sys
import copy
import time
import Queue
import supybot.conf as conf
from xml.dom import minidom
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.
__url__ = 'http://supybot.fr.cr/SupySandbox'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

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

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/TWSS/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -53,14 +53,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = 'http://supybot.fr.cr/Trigger'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -73,7 +73,7 @@ class Trigger(callbacks.Plugin):
try:
msg.args = (channel,) + msg.args[1:]
self.Proxy(irc.irc, msg, tokens)
except Exception, e:
except Exception as e:
self.log.exception('Error occured while running triggered command:')
def doJoin(self, irc, msg):
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.
__url__ = '' # 'http://supybot.com/Members/yourname/Trivia/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -53,14 +53,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Twitter/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

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

View File

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

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/TwitterStream/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Untiny/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -53,14 +53,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Variables/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/WebLogs/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

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

View File

@ -53,14 +53,15 @@ __contributors__ = {}
__url__ = 'http://supybot.fr.cr/WebStats'
# 'http://supybot.com/Members/yourname/WebStats/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

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

View File

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

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Website/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

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

View File

@ -50,14 +50,15 @@ __contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/WikiTrans/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

@ -29,6 +29,8 @@
###
from __future__ import unicode_literals
from supybot.test import *
class WikiTransTestCase(PluginTestCase):
@ -41,7 +43,7 @@ class WikiTransTestCase(PluginTestCase):
self.assertResponse('translate en fr IRC bot', 'Robot IRC')
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 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.
__url__ = '' # 'http://supybot.com/Members/yourname/Wikipedia/download'
import config
import plugin
from . import config
from . import plugin
from imp import reload
reload(plugin) # In case we're being reloaded.
# 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!
if world.testing:
import test
from . import test
Class = plugin.Class
configure = config.configure

View File

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