From c3a2c800f1c36adff0db9651c2d74c3f6a648f84 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Tue, 11 Aug 2015 16:50:23 +0200 Subject: [PATCH] Remove need for 2to3. --- 2to3/__init__.py | 0 2to3/fix_def_iteritems.py | 22 ------ 2to3/fix_def_iterkeys.py | 22 ------ 2to3/fix_def_itervalues.py | 22 ------ 2to3/fix_import.py | 106 --------------------------- 2to3/fix_reload.py | 27 ------- 2to3/run.py | 43 ----------- plugins/Admin/__init__.py | 7 +- plugins/Aka/__init__.py | 1 + plugins/Aka/plugin.py | 2 +- plugins/Aka/test.py | 2 +- plugins/Alias/__init__.py | 9 ++- plugins/Alias/plugin.py | 2 +- plugins/Alias/test.py | 2 +- plugins/Anonymous/__init__.py | 7 +- plugins/AutoMode/__init__.py | 7 +- plugins/BadWords/__init__.py | 7 +- plugins/Channel/__init__.py | 7 +- plugins/ChannelLogger/__init__.py | 7 +- plugins/ChannelLogger/plugin.py | 2 +- plugins/ChannelStats/__init__.py | 7 +- plugins/Conditional/__init__.py | 7 +- plugins/Config/__init__.py | 7 +- plugins/Ctcp/__init__.py | 7 +- plugins/Debug/__init__.py | 1 + plugins/Dict/__init__.py | 7 +- plugins/Dict/plugin.py | 2 +- plugins/Dunno/__init__.py | 7 +- plugins/Factoids/__init__.py | 7 +- plugins/Factoids/plugin.py | 2 +- plugins/Filter/__init__.py | 7 +- plugins/Filter/plugin.py | 2 +- plugins/Format/__init__.py | 7 +- plugins/GPG/__init__.py | 1 + plugins/GPG/plugin.py | 2 +- plugins/GPG/test.py | 2 +- plugins/Games/__init__.py | 7 +- plugins/Google/__init__.py | 7 +- plugins/Google/plugin.py | 2 +- plugins/Herald/__init__.py | 7 +- plugins/Internet/__init__.py | 7 +- plugins/Karma/__init__.py | 7 +- plugins/Karma/plugin.py | 2 +- plugins/Lart/__init__.py | 7 +- plugins/Later/__init__.py | 7 +- plugins/Limiter/__init__.py | 7 +- plugins/Math/__init__.py | 7 +- plugins/Math/local/convertcore.py | 2 +- plugins/Math/plugin.py | 4 +- plugins/MessageParser/__init__.py | 7 +- plugins/MessageParser/plugin.py | 2 +- plugins/Misc/__init__.py | 7 +- plugins/Misc/plugin.py | 2 +- plugins/MoobotFactoids/__init__.py | 7 +- plugins/MoobotFactoids/plugin.py | 2 +- plugins/MoobotFactoids/test.py | 2 +- plugins/Network/__init__.py | 7 +- plugins/News/__init__.py | 7 +- plugins/NickAuth/__init__.py | 7 +- plugins/NickCapture/__init__.py | 7 +- plugins/Nickometer/__init__.py | 7 +- plugins/Nickometer/plugin.py | 3 +- plugins/Note/__init__.py | 7 +- plugins/Owner/__init__.py | 7 +- plugins/Owner/plugin.py | 3 +- plugins/Plugin/__init__.py | 7 +- plugins/PluginDownloader/__init__.py | 7 +- plugins/PluginDownloader/plugin.py | 2 +- plugins/PluginDownloader/test.py | 2 +- plugins/Praise/__init__.py | 7 +- plugins/Protector/__init__.py | 7 +- plugins/Quote/__init__.py | 7 +- plugins/QuoteGrabs/__init__.py | 7 +- plugins/QuoteGrabs/plugin.py | 2 +- plugins/RSS/__init__.py | 7 +- plugins/RSS/plugin.py | 2 +- plugins/RSS/test.py | 2 +- plugins/Relay/__init__.py | 7 +- plugins/Reply/__init__.py | 7 +- plugins/Scheduler/__init__.py | 7 +- plugins/Scheduler/plugin.py | 2 +- plugins/Seen/__init__.py | 7 +- plugins/Seen/plugin.py | 2 +- plugins/Services/__init__.py | 7 +- plugins/Services/plugin.py | 2 +- plugins/ShrinkUrl/__init__.py | 7 +- plugins/Status/__init__.py | 7 +- plugins/String/__init__.py | 7 +- plugins/String/plugin.py | 2 +- plugins/Success/__init__.py | 7 +- plugins/Time/__init__.py | 7 +- plugins/Todo/__init__.py | 7 +- plugins/Topic/__init__.py | 7 +- plugins/Topic/plugin.py | 2 +- plugins/URL/__init__.py | 7 +- plugins/URL/plugin.py | 2 +- plugins/Unix/__init__.py | 7 +- plugins/Unix/config.py | 2 +- plugins/Unix/plugin.py | 2 +- plugins/User/__init__.py | 7 +- plugins/Utilities/__init__.py | 7 +- plugins/Web/__init__.py | 7 +- plugins/Web/plugin.py | 2 +- setup.py | 55 -------------- src/__init__.py | 2 +- src/callbacks.py | 14 ++-- src/cdb.py | 5 +- src/commands.py | 3 +- src/dbi.py | 3 +- src/drivers/Socket.py | 3 +- src/drivers/__init__.py | 3 +- src/gpg.py | 2 +- src/httpserver.py | 5 +- src/ircdb.py | 3 +- src/irclib.py | 9 +-- src/ircmsgs.py | 3 +- src/ircutils.py | 2 +- src/log.py | 8 +- src/questions.py | 3 +- src/registry.py | 3 +- src/shlex.py | 2 +- src/test.py | 3 +- src/utils/__init__.py | 2 +- src/utils/error.py | 2 +- src/utils/gen.py | 2 +- src/utils/iter.py | 2 +- src/{ => utils}/minisix.py | 2 + src/utils/python.py | 21 +++--- src/utils/str.py | 4 +- src/utils/web.py | 2 +- src/world.py | 3 +- test/test_callbacks.py | 2 +- test/test_commands.py | 2 +- test/test_firewall.py | 2 +- test/test_utils.py | 2 +- 135 files changed, 346 insertions(+), 565 deletions(-) delete mode 100644 2to3/__init__.py delete mode 100644 2to3/fix_def_iteritems.py delete mode 100644 2to3/fix_def_iterkeys.py delete mode 100644 2to3/fix_def_itervalues.py delete mode 100644 2to3/fix_import.py delete mode 100644 2to3/fix_reload.py delete mode 100755 2to3/run.py rename src/{ => utils}/minisix.py (98%) diff --git a/2to3/__init__.py b/2to3/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/2to3/fix_def_iteritems.py b/2to3/fix_def_iteritems.py deleted file mode 100644 index f6f299856..000000000 --- a/2to3/fix_def_iteritems.py +++ /dev/null @@ -1,22 +0,0 @@ -"""Fixer for iteritems -> items methods.""" -# Author: Valentin Lorentz - -# Code modified from fix_nonzero by Collin Winter - -from lib2to3 import fixer_base -from lib2to3.fixer_util import Name, syms - -class FixDefIteritems(fixer_base.BaseFix): - BM_compatible = True - PATTERN = """ - classdef< 'class' any+ ':' - suite< any* - funcdef< 'def' name='iteritems' - parameters< '(' NAME ')' > any+ > - any* > > - """ - - def transform(self, node, results): - name = results["name"] - new = Name("items", prefix=name.prefix) - name.replace(new) diff --git a/2to3/fix_def_iterkeys.py b/2to3/fix_def_iterkeys.py deleted file mode 100644 index 4beb6f7b3..000000000 --- a/2to3/fix_def_iterkeys.py +++ /dev/null @@ -1,22 +0,0 @@ -"""Fixer for iterkeys -> keys methods.""" -# Author: Valentin Lorentz - -# Code modified from fix_nonzero by Collin Winter - -from lib2to3 import fixer_base -from lib2to3.fixer_util import Name, syms - -class FixDefIterkeys(fixer_base.BaseFix): - BM_compatible = True - PATTERN = """ - classdef< 'class' any+ ':' - suite< any* - funcdef< 'def' name='iterkeys' - parameters< '(' NAME ')' > any+ > - any* > > - """ - - def transform(self, node, results): - name = results["name"] - new = Name("keys", prefix=name.prefix) - name.replace(new) diff --git a/2to3/fix_def_itervalues.py b/2to3/fix_def_itervalues.py deleted file mode 100644 index 97b48e86d..000000000 --- a/2to3/fix_def_itervalues.py +++ /dev/null @@ -1,22 +0,0 @@ -"""Fixer for itervalues -> values methods.""" -# Author: Valentin Lorentz - -# Code modified from fix_nonzero by Collin Winter - -from lib2to3 import fixer_base -from lib2to3.fixer_util import Name, syms - -class FixDefItervalues(fixer_base.BaseFix): - BM_compatible = True - PATTERN = """ - classdef< 'class' any+ ':' - suite< any* - funcdef< 'def' name='itervalues' - parameters< '(' NAME ')' > any+ > - any* > > - """ - - def transform(self, node, results): - name = results["name"] - new = Name("values", prefix=name.prefix) - name.replace(new) diff --git a/2to3/fix_import.py b/2to3/fix_import.py deleted file mode 100644 index 01ffedefc..000000000 --- a/2to3/fix_import.py +++ /dev/null @@ -1,106 +0,0 @@ -"""Fixer for import statements. -If spam is being imported from the local directory, this import: - from spam import eggs -Becomes: - from .spam import eggs - -And this import: - import spam -Becomes: - from . import spam -""" - -# Local imports -from lib2to3 import fixer_base -from os.path import dirname, join, exists, sep, split, isdir -from os import listdir -from lib2to3.fixer_util import FromImport, syms, token - - -def traverse_imports(names): - """ - Walks over all the names imported in a dotted_as_names node. - """ - pending = [names] - while pending: - node = pending.pop() - if node.type == token.NAME: - yield node.value - elif node.type == syms.dotted_name: - yield "".join([ch.value for ch in node.children]) - elif node.type == syms.dotted_as_name: - pending.append(node.children[0]) - elif node.type == syms.dotted_as_names: - pending.extend(node.children[::-2]) - else: - raise AssertionError("unkown node type") - - -class FixImport(fixer_base.BaseFix): - BM_compatible = True - - PATTERN = """ - import_from< 'from' imp=any 'import' ['('] any [')'] > - | - import_name< 'import' imp=any > - """ - - def start_tree(self, tree, name): - super(FixImport, self).start_tree(tree, name) - self.skip = "absolute_import" in tree.future_features - - def transform(self, node, results): - if self.skip: - return - imp = results['imp'] - - if node.type == syms.import_from: - # Some imps are top-level (eg: 'import ham') - # some are first level (eg: 'import ham.eggs') - # some are third level (eg: 'import ham.eggs as spam') - # Hence, the loop - while not hasattr(imp, 'value'): - imp = imp.children[0] - if self.probably_a_local_import(imp.value): - imp.value = "." + imp.value - imp.changed() - else: - have_local = False - have_absolute = False - for mod_name in traverse_imports(imp): - if self.probably_a_local_import(mod_name): - have_local = True - else: - have_absolute = True - if have_absolute: - if have_local: - # We won't handle both sibling and absolute imports in the - # same statement at the moment. - self.warning(node, "absolute and local imports together") - return - - new = FromImport(".", [imp]) - new.prefix = node.prefix - return new - - def probably_a_local_import(self, imp_name): - if imp_name.startswith("."): - # Relative imports are certainly not local imports. - return False - imp_name = imp_name.split(".", 1)[0] - base_path = dirname(self.filename) - base_path = join(base_path, imp_name) - # If there is no __init__.py next to the file its not in a package - # so can't be a relative import. - if not exists(join(dirname(base_path), "__init__.py")): - return False - (path, filename) = split(base_path) - if isdir(base_path) and filename in listdir(path): - # We use listdir too because of case-insensitivity on Windows - return True - for ext in [".py", ".pyc", ".so", ".sl", ".pyd"]: - if (filename + ext) in listdir(path): - # We use this instead of os.path.exists because of case-insensitivity - # on Windows - return True - return False diff --git a/2to3/fix_reload.py b/2to3/fix_reload.py deleted file mode 100644 index 99704138b..000000000 --- a/2to3/fix_reload.py +++ /dev/null @@ -1,27 +0,0 @@ -# Based on fix_intern.py. Original copyright: -# Copyright 2006 Georg Brandl. -# Licensed to PSF under a Contributor Agreement. - -"""Fixer for intern(). - -intern(s) -> sys.intern(s)""" - -# Local imports -from lib2to3 import pytree -from lib2to3 import fixer_base -from lib2to3.fixer_util import Name, Attr, touch_import - - -class FixReload(fixer_base.BaseFix): - BM_compatible = True - order = "pre" - - PATTERN = """ - power< 'reload' - after=any* - > - """ - - def transform(self, node, results): - touch_import('imp', 'reload', node) - return node diff --git a/2to3/run.py b/2to3/run.py deleted file mode 100755 index 8f0f420e3..000000000 --- a/2to3/run.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env python -import os -import sys -import shutil -from glob import glob -try: - from lib2to3.main import main -except ImportError: - print('Error: you need the 2to3 tool to run this script.') -os.chdir(os.path.join(os.path.dirname(__file__), '..')) -try: - os.unlink('src/version.py') -except OSError: - pass -try: - shutil.rmtree('py3k') -except OSError: - pass -os.mkdir('py3k') -for dirname in ('locales', 'docs', 'plugins', 'src', 'test', 'scripts'): - shutil.copytree(dirname, os.path.join('py3k', dirname)) -for filename in ('setup.py',): - shutil.copyfile(filename, os.path.join('py3k', filename)) -os.chdir('py3k') - -files = ['run.py', 'src', 'plugins', 'test', 'setup.py'] + glob('scripts/*') -args = ['-wn'] -fixers = [] -for fix in ['all', 'def_iteritems', 'def_itervalues', 'def_iterkeys', 'reload', 'import']: - fixers += ['-f', fix] -sys.argv = files + args + fixers + sys.argv -sys.argc = len(sys.argv) - -from . import fix_def_iteritems, fix_def_itervalues, fix_def_iterkeys, fix_reload, fix_import - -# Hacks -sys.modules['lib2to3.fixes.fix_def_iteritems'] = fix_def_iteritems -sys.modules['lib2to3.fixes.fix_def_itervalues'] = fix_def_itervalues -sys.modules['lib2to3.fixes.fix_def_iterkeys'] = fix_def_iterkeys -sys.modules['lib2to3.fixes.fix_reload'] = fix_reload -sys.modules['lib2to3.fixes.fix_import'] = fix_import - -sys.exit(main("lib2to3.fixes")) diff --git a/plugins/Admin/__init__.py b/plugins/Admin/__init__.py index 1a915a667..9c7f6c253 100644 --- a/plugins/Admin/__init__.py +++ b/plugins/Admin/__init__.py @@ -45,12 +45,13 @@ __version__ = "%%VERSION%%" # contributions. __contributors__ = {} -import config -import plugin +from . import config +from . import plugin +from imp import reload reload(plugin) # In case we're being reloaded. if world.testing: - import test + from . import test Class = plugin.Class configure = config.configure diff --git a/plugins/Aka/__init__.py b/plugins/Aka/__init__.py index f6f870dda..333dff791 100644 --- a/plugins/Aka/__init__.py +++ b/plugins/Aka/__init__.py @@ -53,6 +53,7 @@ __url__ = '' # 'http://supybot.com/Members/yourname/Aka/download' from . import config from . import plugin from imp import reload +from imp import reload # In case we're being reloaded. reload(config) reload(plugin) diff --git a/plugins/Aka/plugin.py b/plugins/Aka/plugin.py index 0529c6363..4fb2f1fdf 100644 --- a/plugins/Aka/plugin.py +++ b/plugins/Aka/plugin.py @@ -38,7 +38,7 @@ import supybot.utils as utils import supybot.ircdb as ircdb from supybot.commands import * import supybot.plugins as plugins -import supybot.minisix as minisix +import supybot.utils.minisix as minisix import supybot.ircutils as ircutils import supybot.callbacks as callbacks from supybot.i18n import PluginInternationalization diff --git a/plugins/Aka/test.py b/plugins/Aka/test.py index 056a0ecc3..42113f527 100644 --- a/plugins/Aka/test.py +++ b/plugins/Aka/test.py @@ -35,7 +35,7 @@ import supybot.plugin as plugin import supybot.registry as registry from supybot.minisix import u -import plugin as Aka +from . import plugin as Aka class FunctionsTest(SupyTestCase): def testFindBiggestDollar(self): diff --git a/plugins/Alias/__init__.py b/plugins/Alias/__init__.py index 3a88b0713..5f08b65f8 100644 --- a/plugins/Alias/__init__.py +++ b/plugins/Alias/__init__.py @@ -45,15 +45,16 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -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! -from plugin import findBiggestDollar, AliasError, escapeAlias, unescapeAlias # for the tests. +from .plugin import findBiggestDollar, AliasError, escapeAlias, unescapeAlias # for the tests. if world.testing: - import test + from . import test Class = plugin.Class configure = config.configure diff --git a/plugins/Alias/plugin.py b/plugins/Alias/plugin.py index c4cd5663f..bd3d37353 100644 --- a/plugins/Alias/plugin.py +++ b/plugins/Alias/plugin.py @@ -35,7 +35,7 @@ import types import supybot.conf as conf import supybot.utils as utils from supybot.commands import * -import supybot.minisix as minisix +import supybot.utils.minisix as minisix import supybot.ircutils as ircutils import supybot.registry as registry import supybot.callbacks as callbacks diff --git a/plugins/Alias/test.py b/plugins/Alias/test.py index 5a9e24191..d35a9c914 100644 --- a/plugins/Alias/test.py +++ b/plugins/Alias/test.py @@ -34,7 +34,7 @@ import supybot.conf as conf import supybot.plugin as plugin import supybot.registry as registry -import plugin as Alias +from . import plugin as Alias class FunctionsTest(SupyTestCase): def testFindBiggestDollar(self): diff --git a/plugins/Anonymous/__init__.py b/plugins/Anonymous/__init__.py index 5e491b240..011e0a67b 100644 --- a/plugins/Anonymous/__init__.py +++ b/plugins/Anonymous/__init__.py @@ -45,14 +45,15 @@ __author__ = supybot.authors.strike # contributions. __contributors__ = {} -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 diff --git a/plugins/AutoMode/__init__.py b/plugins/AutoMode/__init__.py index 1acc9b740..1079674d6 100644 --- a/plugins/AutoMode/__init__.py +++ b/plugins/AutoMode/__init__.py @@ -46,14 +46,15 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -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 diff --git a/plugins/BadWords/__init__.py b/plugins/BadWords/__init__.py index a605bcd56..ab519b2cd 100644 --- a/plugins/BadWords/__init__.py +++ b/plugins/BadWords/__init__.py @@ -45,14 +45,15 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -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 diff --git a/plugins/Channel/__init__.py b/plugins/Channel/__init__.py index 9bff7a104..04fee5246 100644 --- a/plugins/Channel/__init__.py +++ b/plugins/Channel/__init__.py @@ -47,12 +47,13 @@ __contributors__ = { supybot.authors.skorobeus: ['enable', 'disable'], } -import config -import plugin +from . import config +from . import plugin +from imp import reload reload(plugin) # In case we're being reloaded. if world.testing: - import test + from . import test Class = plugin.Class configure = config.configure diff --git a/plugins/ChannelLogger/__init__.py b/plugins/ChannelLogger/__init__.py index bd57813dc..bd0406290 100644 --- a/plugins/ChannelLogger/__init__.py +++ b/plugins/ChannelLogger/__init__.py @@ -44,14 +44,15 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -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 diff --git a/plugins/ChannelLogger/plugin.py b/plugins/ChannelLogger/plugin.py index 7f9c8ecfd..286ee3524 100644 --- a/plugins/ChannelLogger/plugin.py +++ b/plugins/ChannelLogger/plugin.py @@ -36,7 +36,7 @@ import supybot.conf as conf import supybot.world as world import supybot.ircdb as ircdb import supybot.irclib as irclib -import supybot.minisix as minisix +import supybot.utils.minisix as minisix import supybot.ircmsgs as ircmsgs import supybot.ircutils as ircutils import supybot.registry as registry diff --git a/plugins/ChannelStats/__init__.py b/plugins/ChannelStats/__init__.py index 6db2824d3..1622bd5cd 100644 --- a/plugins/ChannelStats/__init__.py +++ b/plugins/ChannelStats/__init__.py @@ -46,14 +46,15 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -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 diff --git a/plugins/Conditional/__init__.py b/plugins/Conditional/__init__.py index d142ce54f..ca0402673 100644 --- a/plugins/Conditional/__init__.py +++ b/plugins/Conditional/__init__.py @@ -51,14 +51,15 @@ __contributors__ = {} # This is a url where the most recent plugin package can be downloaded. __url__ = '' # 'http://supybot.com/Members/yourname/Conditional/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 diff --git a/plugins/Config/__init__.py b/plugins/Config/__init__.py index 27bdd84ea..f7c3161ef 100644 --- a/plugins/Config/__init__.py +++ b/plugins/Config/__init__.py @@ -44,12 +44,13 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -import config -import plugin +from . import config +from . import plugin +from imp import reload reload(plugin) # In case we're being reloaded. if world.testing: - import test + from . import test Class = plugin.Class configure = config.configure diff --git a/plugins/Ctcp/__init__.py b/plugins/Ctcp/__init__.py index 32670a208..129d6ac2b 100644 --- a/plugins/Ctcp/__init__.py +++ b/plugins/Ctcp/__init__.py @@ -43,14 +43,15 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -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 diff --git a/plugins/Debug/__init__.py b/plugins/Debug/__init__.py index f6abf963f..e38e7d4dd 100644 --- a/plugins/Debug/__init__.py +++ b/plugins/Debug/__init__.py @@ -46,6 +46,7 @@ __contributors__ = {} from . import config from . import plugin +from imp import reload if version_info[0] >= 3: from imp import reload reload(plugin) # In case we're being reloaded. diff --git a/plugins/Dict/__init__.py b/plugins/Dict/__init__.py index 251c49e05..513104148 100644 --- a/plugins/Dict/__init__.py +++ b/plugins/Dict/__init__.py @@ -44,12 +44,13 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -import config -import plugin +from . import config +from . import plugin +from imp import reload reload(plugin) # In case we're being reloaded. if world.testing: - import test + from . import test Class = plugin.Class configure = config.configure diff --git a/plugins/Dict/plugin.py b/plugins/Dict/plugin.py index 68dcb9d27..e0049fe4f 100644 --- a/plugins/Dict/plugin.py +++ b/plugins/Dict/plugin.py @@ -40,7 +40,7 @@ _ = PluginInternationalization('Dict') import random -from local import dictclient +from .local import dictclient class Dict(callbacks.Plugin): """This plugin provides a function to look up words from different diff --git a/plugins/Dunno/__init__.py b/plugins/Dunno/__init__.py index edae3794c..0174dcbdf 100644 --- a/plugins/Dunno/__init__.py +++ b/plugins/Dunno/__init__.py @@ -48,14 +48,15 @@ __contributors__ = { supybot.authors.jemfinch: ['Flatfile DB implementation.'], } -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 diff --git a/plugins/Factoids/__init__.py b/plugins/Factoids/__init__.py index f8dd470a2..e064f0cba 100644 --- a/plugins/Factoids/__init__.py +++ b/plugins/Factoids/__init__.py @@ -48,14 +48,15 @@ __contributors__ = {} # This is a url where the most recent plugin package can be downloaded. __url__ = '' # 'http://supybot.com/Members/yourname/Factoids/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 diff --git a/plugins/Factoids/plugin.py b/plugins/Factoids/plugin.py index 388a3fe15..7c0f10563 100644 --- a/plugins/Factoids/plugin.py +++ b/plugins/Factoids/plugin.py @@ -38,7 +38,7 @@ import supybot.ircdb as ircdb import supybot.utils as utils from supybot.commands import * import supybot.plugins as plugins -import supybot.minisix as minisix +import supybot.utils.minisix as minisix import supybot.ircutils as ircutils import supybot.callbacks as callbacks import supybot.httpserver as httpserver diff --git a/plugins/Filter/__init__.py b/plugins/Filter/__init__.py index caf4ba954..cf46f1d71 100644 --- a/plugins/Filter/__init__.py +++ b/plugins/Filter/__init__.py @@ -45,12 +45,13 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -import config -import plugin +from . import config +from . import plugin +from imp import reload reload(plugin) # In case we're being reloaded. if world.testing: - import test + from . import test Class = plugin.Class configure = config.configure diff --git a/plugins/Filter/plugin.py b/plugins/Filter/plugin.py index c9d614106..b13cf672a 100644 --- a/plugins/Filter/plugin.py +++ b/plugins/Filter/plugin.py @@ -39,7 +39,7 @@ import random import supybot.conf as conf import supybot.utils as utils from supybot.commands import * -import supybot.minisix as minisix +import supybot.utils.minisix as minisix import supybot.ircmsgs as ircmsgs import supybot.ircutils as ircutils import supybot.callbacks as callbacks diff --git a/plugins/Format/__init__.py b/plugins/Format/__init__.py index 4ed3a6f03..f9edde02c 100644 --- a/plugins/Format/__init__.py +++ b/plugins/Format/__init__.py @@ -44,12 +44,13 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -import config -import plugin +from . import config +from . import plugin +from imp import reload reload(plugin) # In case we're being reloaded. if world.testing: - import test + from . import test Class = plugin.Class configure = config.configure diff --git a/plugins/GPG/__init__.py b/plugins/GPG/__init__.py index 9ff5de97b..e409061c6 100644 --- a/plugins/GPG/__init__.py +++ b/plugins/GPG/__init__.py @@ -52,6 +52,7 @@ __url__ = '' from . import config from . import plugin from imp import reload +from imp import reload # In case we're being reloaded. reload(config) reload(plugin) diff --git a/plugins/GPG/plugin.py b/plugins/GPG/plugin.py index b4ea2f962..b34aa925e 100644 --- a/plugins/GPG/plugin.py +++ b/plugins/GPG/plugin.py @@ -38,7 +38,7 @@ import supybot.conf as conf import supybot.utils as utils import supybot.ircdb as ircdb from supybot.commands import * -import supybot.minisix as minisix +import supybot.utils.minisix as minisix import supybot.plugins as plugins import supybot.ircutils as ircutils import supybot.callbacks as callbacks diff --git a/plugins/GPG/test.py b/plugins/GPG/test.py index bb8f977d2..a84bdbf58 100644 --- a/plugins/GPG/test.py +++ b/plugins/GPG/test.py @@ -29,7 +29,7 @@ ### from supybot.test import * -import supybot.minisix as minisix +import supybot.utils.minisix as minisix import supybot.gpg as gpg diff --git a/plugins/Games/__init__.py b/plugins/Games/__init__.py index e029b3641..074a9ade1 100644 --- a/plugins/Games/__init__.py +++ b/plugins/Games/__init__.py @@ -44,14 +44,15 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -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 diff --git a/plugins/Google/__init__.py b/plugins/Google/__init__.py index 83d6ec0a9..6a7025dfb 100644 --- a/plugins/Google/__init__.py +++ b/plugins/Google/__init__.py @@ -44,14 +44,15 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -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 diff --git a/plugins/Google/plugin.py b/plugins/Google/plugin.py index a8d470c45..bc6915184 100644 --- a/plugins/Google/plugin.py +++ b/plugins/Google/plugin.py @@ -39,7 +39,7 @@ import supybot.conf as conf import supybot.utils as utils import supybot.world as world from supybot.commands import * -import supybot.minisix as minisix +import supybot.utils.minisix as minisix import supybot.ircmsgs as ircmsgs import supybot.ircutils as ircutils import supybot.callbacks as callbacks diff --git a/plugins/Herald/__init__.py b/plugins/Herald/__init__.py index cd6315685..d258de9ac 100644 --- a/plugins/Herald/__init__.py +++ b/plugins/Herald/__init__.py @@ -45,12 +45,13 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -import config -import plugin +from . import config +from . import plugin +from imp import reload reload(plugin) # In case we're being reloaded. if world.testing: - import test + from . import test Class = plugin.Class configure = config.configure diff --git a/plugins/Internet/__init__.py b/plugins/Internet/__init__.py index d58de5679..dc944cf96 100644 --- a/plugins/Internet/__init__.py +++ b/plugins/Internet/__init__.py @@ -44,14 +44,15 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {supybot.authors.jamessan: ['whois']} -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 diff --git a/plugins/Karma/__init__.py b/plugins/Karma/__init__.py index bd8aeb177..56fd0164b 100644 --- a/plugins/Karma/__init__.py +++ b/plugins/Karma/__init__.py @@ -45,14 +45,15 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -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 diff --git a/plugins/Karma/plugin.py b/plugins/Karma/plugin.py index 3b5e704a6..d3d1f8698 100644 --- a/plugins/Karma/plugin.py +++ b/plugins/Karma/plugin.py @@ -35,7 +35,7 @@ import csv import supybot.conf as conf import supybot.utils as utils from supybot.commands import * -import supybot.minisix as minisix +import supybot.utils.minisix as minisix import supybot.plugins as plugins import supybot.ircmsgs as ircmsgs import supybot.ircutils as ircutils diff --git a/plugins/Lart/__init__.py b/plugins/Lart/__init__.py index 1a0423dc7..bf1f574b3 100644 --- a/plugins/Lart/__init__.py +++ b/plugins/Lart/__init__.py @@ -45,14 +45,15 @@ __author__ = supybot.authors.strike # contributions. __contributors__ = {} -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 diff --git a/plugins/Later/__init__.py b/plugins/Later/__init__.py index d18dafba1..e818461b2 100644 --- a/plugins/Later/__init__.py +++ b/plugins/Later/__init__.py @@ -46,14 +46,15 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -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 diff --git a/plugins/Limiter/__init__.py b/plugins/Limiter/__init__.py index fc49db4fa..8cd864ad8 100644 --- a/plugins/Limiter/__init__.py +++ b/plugins/Limiter/__init__.py @@ -44,14 +44,15 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -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 diff --git a/plugins/Math/__init__.py b/plugins/Math/__init__.py index bd9a356c7..fb1abe29c 100644 --- a/plugins/Math/__init__.py +++ b/plugins/Math/__init__.py @@ -44,12 +44,13 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {supybot.Author('Keith Jones', 'kmj', ''): ['convert']} -import config -import plugin +from . import config +from . import plugin +from imp import reload reload(plugin) # In case we're being reloaded. if world.testing: - import test + from . import test Class = plugin.Class configure = config.configure diff --git a/plugins/Math/local/convertcore.py b/plugins/Math/local/convertcore.py index b038755e1..df5043e94 100644 --- a/plugins/Math/local/convertcore.py +++ b/plugins/Math/local/convertcore.py @@ -13,7 +13,7 @@ import re, copy, sys, os.path import supybot.conf as conf -import supybot.minisix as minisix +import supybot.utils.minisix as minisix import supybot.registry as registry unitData = \ diff --git a/plugins/Math/plugin.py b/plugins/Math/plugin.py index 46476193b..518d21c7b 100644 --- a/plugins/Math/plugin.py +++ b/plugins/Math/plugin.py @@ -38,13 +38,13 @@ import string import supybot.utils as utils from supybot.commands import * -import supybot.minisix as minisix +import supybot.utils.minisix as minisix import supybot.callbacks as callbacks from supybot.i18n import PluginInternationalization, internationalizeDocstring _ = PluginInternationalization('Math') try: - from local import convertcore + from .local import convertcore except ImportError: from .local import convertcore diff --git a/plugins/MessageParser/__init__.py b/plugins/MessageParser/__init__.py index 8e321977c..ed453ef3b 100644 --- a/plugins/MessageParser/__init__.py +++ b/plugins/MessageParser/__init__.py @@ -51,14 +51,15 @@ __contributors__ = {} # This is a url where the most recent plugin package can be downloaded. __url__ = '' # 'http://supybot.com/Members/yourname/MessageParser/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 diff --git a/plugins/MessageParser/plugin.py b/plugins/MessageParser/plugin.py index b7668d773..4bc5e23de 100644 --- a/plugins/MessageParser/plugin.py +++ b/plugins/MessageParser/plugin.py @@ -30,7 +30,7 @@ import supybot.utils as utils from supybot.commands import * -import supybot.minisix as minisix +import supybot.utils.minisix as minisix import supybot.plugins as plugins import supybot.ircutils as ircutils import supybot.callbacks as callbacks diff --git a/plugins/Misc/__init__.py b/plugins/Misc/__init__.py index 67c0e2677..95dbd64b1 100644 --- a/plugins/Misc/__init__.py +++ b/plugins/Misc/__init__.py @@ -44,12 +44,13 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -import config -import plugin +from . import config +from . import plugin +from imp import reload reload(plugin) # In case we're being reloaded. if world.testing: - import test + from . import test Class = plugin.Class configure = config.configure diff --git a/plugins/Misc/plugin.py b/plugins/Misc/plugin.py index 00fd32eb9..bb85ce43d 100644 --- a/plugins/Misc/plugin.py +++ b/plugins/Misc/plugin.py @@ -44,7 +44,7 @@ import supybot.utils as utils from supybot.commands import * import supybot.ircdb as ircdb import supybot.irclib as irclib -import supybot.minisix as minisix +import supybot.utils.minisix as minisix import supybot.ircmsgs as ircmsgs import supybot.ircutils as ircutils import supybot.callbacks as callbacks diff --git a/plugins/MoobotFactoids/__init__.py b/plugins/MoobotFactoids/__init__.py index 83afc0a7b..3b4d71ab7 100644 --- a/plugins/MoobotFactoids/__init__.py +++ b/plugins/MoobotFactoids/__init__.py @@ -46,14 +46,15 @@ __author__ = supybot.authors.strike # contributions. __contributors__ = {} -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 diff --git a/plugins/MoobotFactoids/plugin.py b/plugins/MoobotFactoids/plugin.py index d89bea4d2..8f0ce4635 100755 --- a/plugins/MoobotFactoids/plugin.py +++ b/plugins/MoobotFactoids/plugin.py @@ -37,7 +37,7 @@ import supybot.ircdb as ircdb import supybot.utils as utils import supybot.shlex as shlex from supybot.commands import * -import supybot.minisix as minisix +import supybot.utils.minisix as minisix import supybot.plugins as plugins import supybot.ircutils as ircutils import supybot.callbacks as callbacks diff --git a/plugins/MoobotFactoids/test.py b/plugins/MoobotFactoids/test.py index d2c0d49ce..de45a8613 100644 --- a/plugins/MoobotFactoids/test.py +++ b/plugins/MoobotFactoids/test.py @@ -40,7 +40,7 @@ try: except ImportError: sqlite = None -import plugin +from . import plugin MFconf = conf.supybot.plugins.MoobotFactoids class OptionListTestCase(SupyTestCase): diff --git a/plugins/Network/__init__.py b/plugins/Network/__init__.py index 1690059b7..4fb798c07 100644 --- a/plugins/Network/__init__.py +++ b/plugins/Network/__init__.py @@ -45,12 +45,13 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -import config -import plugin +from . import config +from . import plugin +from imp import reload reload(plugin) # In case we're being reloaded. if world.testing: - import test + from . import test Class = plugin.Class configure = config.configure diff --git a/plugins/News/__init__.py b/plugins/News/__init__.py index 890a5dbb2..45eb3221d 100644 --- a/plugins/News/__init__.py +++ b/plugins/News/__init__.py @@ -48,14 +48,15 @@ __contributors__ = {} # This is a url where the most recent plugin package can be downloaded. __url__ = '' # 'http://supybot.com/Members/yourname/News/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 diff --git a/plugins/NickAuth/__init__.py b/plugins/NickAuth/__init__.py index 67466366f..675dc9316 100644 --- a/plugins/NickAuth/__init__.py +++ b/plugins/NickAuth/__init__.py @@ -49,14 +49,15 @@ __contributors__ = {} # This is a url where the most recent plugin package can be downloaded. __url__ = '' # 'http://supybot.com/Members/yourname/NickAuth/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 diff --git a/plugins/NickCapture/__init__.py b/plugins/NickCapture/__init__.py index 738b38728..88da6f503 100644 --- a/plugins/NickCapture/__init__.py +++ b/plugins/NickCapture/__init__.py @@ -45,14 +45,15 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -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 diff --git a/plugins/Nickometer/__init__.py b/plugins/Nickometer/__init__.py index e27199e50..2befe2918 100644 --- a/plugins/Nickometer/__init__.py +++ b/plugins/Nickometer/__init__.py @@ -65,14 +65,15 @@ __author__ = supybot.authors.baggins # contributions. __contributors__ = {} -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 diff --git a/plugins/Nickometer/plugin.py b/plugins/Nickometer/plugin.py index ad4c83ab5..8046dbccf 100644 --- a/plugins/Nickometer/plugin.py +++ b/plugins/Nickometer/plugin.py @@ -54,6 +54,7 @@ import math import string import supybot.utils as utils +import supybot.utils.minisix as minisix import supybot.callbacks as callbacks from supybot.commands import wrap, additional from supybot.i18n import PluginInternationalization, internationalizeDocstring @@ -90,7 +91,7 @@ class Nickometer(callbacks.Plugin): Tells you how lame said nick is. If is not given, uses the nick of the person giving the command. """ - score = 0L + score = minisix.L(0) if not nick: nick = msg.nick originalNick = nick diff --git a/plugins/Note/__init__.py b/plugins/Note/__init__.py index 53a4cd79d..1b43749a4 100644 --- a/plugins/Note/__init__.py +++ b/plugins/Note/__init__.py @@ -45,14 +45,15 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = { supybot.authors.inkedmn: ['Original implementation.'] } -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 diff --git a/plugins/Owner/__init__.py b/plugins/Owner/__init__.py index ff4df09fd..6b8ea7cd2 100644 --- a/plugins/Owner/__init__.py +++ b/plugins/Owner/__init__.py @@ -45,12 +45,13 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -import config -import plugin +from . import config +from . import plugin +from imp import reload reload(plugin) # In case we're being reloaded. if world.testing: - import test + from . import test Class = plugin.Class configure = config.configure diff --git a/plugins/Owner/plugin.py b/plugins/Owner/plugin.py index 67eb4e3a1..b47f81877 100644 --- a/plugins/Owner/plugin.py +++ b/plugins/Owner/plugin.py @@ -48,7 +48,7 @@ import supybot.irclib as irclib import supybot.plugin as plugin import supybot.plugins as plugins import supybot.drivers as drivers -import supybot.minisix as minisix +import supybot.utils.minisix as minisix import supybot.ircmsgs as ircmsgs import supybot.ircutils as ircutils import supybot.registry as registry @@ -465,6 +465,7 @@ class Owner(callbacks.Plugin): if hasattr(module, 'reload') and 'x' in locals(): module.reload(x) if hasattr(module, 'config'): + from imp import reload reload(module.config) for callback in callbacks: callback.die() diff --git a/plugins/Plugin/__init__.py b/plugins/Plugin/__init__.py index e51df2610..83ee468a2 100644 --- a/plugins/Plugin/__init__.py +++ b/plugins/Plugin/__init__.py @@ -49,15 +49,16 @@ __contributors__ = { supybot.authors.skorobeus: ['contributors'], } -import config +from . import config # This had to be renamed because of stupid case-insensitivity issues. -import plugin +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 diff --git a/plugins/PluginDownloader/__init__.py b/plugins/PluginDownloader/__init__.py index 7d92643b3..86c34b70a 100644 --- a/plugins/PluginDownloader/__init__.py +++ b/plugins/PluginDownloader/__init__.py @@ -50,14 +50,15 @@ __contributors__ = {} # This is a url where the most recent plugin package can be downloaded. __url__ = '' # 'http://supybot.com/Members/yourname/PluginDownloader/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 diff --git a/plugins/PluginDownloader/plugin.py b/plugins/PluginDownloader/plugin.py index eddea8abf..d604384c6 100644 --- a/plugins/PluginDownloader/plugin.py +++ b/plugins/PluginDownloader/plugin.py @@ -39,7 +39,7 @@ import supybot.log as log import supybot.conf as conf import supybot.utils as utils from supybot.commands import * -import supybot.minisix as minisix +import supybot.utils.minisix as minisix import supybot.plugins as plugins import supybot.ircutils as ircutils import supybot.callbacks as callbacks diff --git a/plugins/PluginDownloader/test.py b/plugins/PluginDownloader/test.py index a0353013f..91469d4a9 100644 --- a/plugins/PluginDownloader/test.py +++ b/plugins/PluginDownloader/test.py @@ -33,7 +33,7 @@ import sys import shutil from supybot.test import * -import supybot.minisix as minisix +import supybot.utils.minisix as minisix pluginsPath = '%s/test-plugins' % os.getcwd() diff --git a/plugins/Praise/__init__.py b/plugins/Praise/__init__.py index eab60ca1f..c605f6edb 100644 --- a/plugins/Praise/__init__.py +++ b/plugins/Praise/__init__.py @@ -45,14 +45,15 @@ __author__ = supybot.authors.strike # contributions. __contributors__ = {} -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 diff --git a/plugins/Protector/__init__.py b/plugins/Protector/__init__.py index 1427ac5e6..10119a1a3 100644 --- a/plugins/Protector/__init__.py +++ b/plugins/Protector/__init__.py @@ -45,14 +45,15 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -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 diff --git a/plugins/Quote/__init__.py b/plugins/Quote/__init__.py index 92b7e5551..65208164a 100644 --- a/plugins/Quote/__init__.py +++ b/plugins/Quote/__init__.py @@ -45,14 +45,15 @@ __author__ = supybot.authors.strike # contributions. __contributors__ = {} -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 diff --git a/plugins/QuoteGrabs/__init__.py b/plugins/QuoteGrabs/__init__.py index 2df993436..790bfde1a 100644 --- a/plugins/QuoteGrabs/__init__.py +++ b/plugins/QuoteGrabs/__init__.py @@ -49,12 +49,13 @@ __author__ = supybot.authors.strike # contributions. __contributors__ = {} -import config -import plugin +from . import config +from . import plugin +from imp import reload reload(plugin) # In case we're being reloaded. if world.testing: - import test + from . import test Class = plugin.Class configure = config.configure diff --git a/plugins/QuoteGrabs/plugin.py b/plugins/QuoteGrabs/plugin.py index 389fda95d..54517681f 100644 --- a/plugins/QuoteGrabs/plugin.py +++ b/plugins/QuoteGrabs/plugin.py @@ -37,7 +37,7 @@ import supybot.dbi as dbi import supybot.conf as conf import supybot.utils as utils from supybot.commands import * -import supybot.minisix as minisix +import supybot.utils.minisix as minisix import supybot.ircmsgs as ircmsgs import supybot.plugins as plugins import supybot.ircutils as ircutils diff --git a/plugins/RSS/__init__.py b/plugins/RSS/__init__.py index 640cf07b0..c06951ee4 100644 --- a/plugins/RSS/__init__.py +++ b/plugins/RSS/__init__.py @@ -44,14 +44,15 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -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 diff --git a/plugins/RSS/plugin.py b/plugins/RSS/plugin.py index f406fb3f4..9b73d9f9c 100644 --- a/plugins/RSS/plugin.py +++ b/plugins/RSS/plugin.py @@ -44,7 +44,7 @@ import supybot.conf as conf import supybot.utils as utils import supybot.world as world from supybot.commands import * -import supybot.minisix as minisix +import supybot.utils.minisix as minisix import supybot.ircmsgs as ircmsgs import supybot.ircutils as ircutils import supybot.registry as registry diff --git a/plugins/RSS/test.py b/plugins/RSS/test.py index e7135742f..24474a44d 100644 --- a/plugins/RSS/test.py +++ b/plugins/RSS/test.py @@ -32,7 +32,7 @@ import sys import feedparser from supybot.test import * import supybot.conf as conf -import supybot.minisix as minisix +import supybot.utils.minisix as minisix xkcd_old = """ xkcd.comhttp://xkcd.com/xkcd.com: A webcomic of romance and math humor.enSnake Factshttp://xkcd.com/1398/<img src="http://imgs.xkcd.com/comics/snake_facts.png" title="Biologically speaking, what we call a 'snake' is actually a human digestive tract which has escaped from its host." alt="Biologically speaking, what we call a 'snake' is actually a human digestive tract which has escaped from its host." />Wed, 23 Jul 2014 04:00:00 -0000http://xkcd.com/1398/ diff --git a/plugins/Relay/__init__.py b/plugins/Relay/__init__.py index 9ed93c243..594a53d31 100644 --- a/plugins/Relay/__init__.py +++ b/plugins/Relay/__init__.py @@ -44,14 +44,15 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -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 diff --git a/plugins/Reply/__init__.py b/plugins/Reply/__init__.py index 7300b6f00..ef94b5d2d 100644 --- a/plugins/Reply/__init__.py +++ b/plugins/Reply/__init__.py @@ -46,14 +46,15 @@ __author__ = supybot.authors.strike # contributions. __contributors__ = {} -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 diff --git a/plugins/Scheduler/__init__.py b/plugins/Scheduler/__init__.py index 609bd6a7b..90de0d4b5 100644 --- a/plugins/Scheduler/__init__.py +++ b/plugins/Scheduler/__init__.py @@ -45,14 +45,15 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -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 diff --git a/plugins/Scheduler/plugin.py b/plugins/Scheduler/plugin.py index 45d52008a..701cc60a2 100644 --- a/plugins/Scheduler/plugin.py +++ b/plugins/Scheduler/plugin.py @@ -41,7 +41,7 @@ from supybot.i18n import PluginInternationalization, internationalizeDocstring _ = PluginInternationalization('Scheduler') import supybot.world as world -import supybot.minisix as minisix +import supybot.utils.minisix as minisix pickle = minisix.pickle datadir = conf.supybot.directories.data() diff --git a/plugins/Seen/__init__.py b/plugins/Seen/__init__.py index 8fd9e8a4e..f65020800 100644 --- a/plugins/Seen/__init__.py +++ b/plugins/Seen/__init__.py @@ -44,14 +44,15 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -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 diff --git a/plugins/Seen/plugin.py b/plugins/Seen/plugin.py index c380909e4..20d8ee328 100644 --- a/plugins/Seen/plugin.py +++ b/plugins/Seen/plugin.py @@ -39,7 +39,7 @@ import supybot.world as world import supybot.ircdb as ircdb from supybot.commands import * import supybot.irclib as irclib -import supybot.minisix as minisix +import supybot.utils.minisix as minisix import supybot.ircmsgs as ircmsgs import supybot.plugins as plugins import supybot.ircutils as ircutils diff --git a/plugins/Services/__init__.py b/plugins/Services/__init__.py index d58434d06..a9af342e2 100644 --- a/plugins/Services/__init__.py +++ b/plugins/Services/__init__.py @@ -44,14 +44,15 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -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 diff --git a/plugins/Services/plugin.py b/plugins/Services/plugin.py index f2183cb55..66764b30d 100644 --- a/plugins/Services/plugin.py +++ b/plugins/Services/plugin.py @@ -31,7 +31,7 @@ import re import time -import config +from . import config import supybot.conf as conf import supybot.utils as utils diff --git a/plugins/ShrinkUrl/__init__.py b/plugins/ShrinkUrl/__init__.py index 90310e8bc..58b651016 100644 --- a/plugins/ShrinkUrl/__init__.py +++ b/plugins/ShrinkUrl/__init__.py @@ -44,14 +44,15 @@ __author__ = supybot.authors.jemfinch __contributors__ = {supybot.authors.jamessan: ['xrl.us support', 'x0.no support']} -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 diff --git a/plugins/Status/__init__.py b/plugins/Status/__init__.py index 7b2eae07f..7f52fb26a 100644 --- a/plugins/Status/__init__.py +++ b/plugins/Status/__init__.py @@ -45,12 +45,13 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -import config -import plugin +from . import config +from . import plugin +from imp import reload reload(plugin) # In case we're being reloaded. if world.testing: - import test + from . import test Class = plugin.Class configure = config.configure diff --git a/plugins/String/__init__.py b/plugins/String/__init__.py index 8dc45d5c0..822de9f9e 100644 --- a/plugins/String/__init__.py +++ b/plugins/String/__init__.py @@ -44,14 +44,15 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -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 diff --git a/plugins/String/plugin.py b/plugins/String/plugin.py index 75eed6101..4e07c02ef 100644 --- a/plugins/String/plugin.py +++ b/plugins/String/plugin.py @@ -37,7 +37,7 @@ import binascii import supybot.utils as utils from supybot.commands import * -import supybot.minisix as minisix +import supybot.utils.minisix as minisix import supybot.plugins as plugins import supybot.commands as commands import supybot.ircutils as ircutils diff --git a/plugins/Success/__init__.py b/plugins/Success/__init__.py index f8dbff767..413f8a0b1 100644 --- a/plugins/Success/__init__.py +++ b/plugins/Success/__init__.py @@ -46,14 +46,15 @@ __author__ = supybot.authors.strike # contributions. __contributors__ = {} -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 diff --git a/plugins/Time/__init__.py b/plugins/Time/__init__.py index 6cf97ccd7..3f96f4e4e 100644 --- a/plugins/Time/__init__.py +++ b/plugins/Time/__init__.py @@ -46,14 +46,15 @@ __contributors__ = {'tztime': supybot.Author('Valentin Lorentz', 'ProgVal', 'progval@gmail.com')} -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 diff --git a/plugins/Todo/__init__.py b/plugins/Todo/__init__.py index 185a2064d..82e9dc2cc 100644 --- a/plugins/Todo/__init__.py +++ b/plugins/Todo/__init__.py @@ -45,14 +45,15 @@ __author__ = supybot.authors.strike # contributions. __contributors__ = {} -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 diff --git a/plugins/Topic/__init__.py b/plugins/Topic/__init__.py index 38f4e7655..ce41f5d46 100644 --- a/plugins/Topic/__init__.py +++ b/plugins/Topic/__init__.py @@ -44,14 +44,15 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = { supybot.authors.stepnem: ['persistence support'] } -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 diff --git a/plugins/Topic/plugin.py b/plugins/Topic/plugin.py index 402b268f4..d67214db8 100644 --- a/plugins/Topic/plugin.py +++ b/plugins/Topic/plugin.py @@ -47,7 +47,7 @@ _ = PluginInternationalization('Topic') import supybot.ircdb as ircdb -import supybot.minisix as minisix +import supybot.utils.minisix as minisix pickle = minisix.pickle def canChangeTopic(irc, msg, args, state): diff --git a/plugins/URL/__init__.py b/plugins/URL/__init__.py index 0223c8ece..d29c26ad6 100644 --- a/plugins/URL/__init__.py +++ b/plugins/URL/__init__.py @@ -46,14 +46,15 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -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 diff --git a/plugins/URL/plugin.py b/plugins/URL/plugin.py index 75c72c2f8..e87997f4f 100644 --- a/plugins/URL/plugin.py +++ b/plugins/URL/plugin.py @@ -32,7 +32,7 @@ import supybot.dbi as dbi import supybot.conf as conf import supybot.utils as utils from supybot.commands import * -import supybot.minisix as minisix +import supybot.utils.minisix as minisix import supybot.plugins as plugins import supybot.ircmsgs as ircmsgs import supybot.ircutils as ircutils diff --git a/plugins/Unix/__init__.py b/plugins/Unix/__init__.py index 08997c864..9ad081be4 100644 --- a/plugins/Unix/__init__.py +++ b/plugins/Unix/__init__.py @@ -47,14 +47,15 @@ __contributors__ = {} # This is a url where the most recent plugin package can be downloaded. __url__ = '' # 'http://supybot.com/Members/yourname/Unix/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 diff --git a/plugins/Unix/config.py b/plugins/Unix/config.py index 1b43aa052..27f5c1ba3 100644 --- a/plugins/Unix/config.py +++ b/plugins/Unix/config.py @@ -33,7 +33,7 @@ import supybot.registry as registry from supybot.i18n import PluginInternationalization, internationalizeDocstring _ = PluginInternationalization('Unix') -import plugin +from . import plugin progstats = plugin.progstats diff --git a/plugins/Unix/plugin.py b/plugins/Unix/plugin.py index 0ceb4f3e0..ec64c74f9 100644 --- a/plugins/Unix/plugin.py +++ b/plugins/Unix/plugin.py @@ -42,7 +42,7 @@ import shlex import supybot.utils as utils from supybot.commands import * -import supybot.minisix as minisix +import supybot.utils.minisix as minisix import supybot.plugins as plugins import supybot.ircutils as ircutils import supybot.registry as registry diff --git a/plugins/User/__init__.py b/plugins/User/__init__.py index 5a7cee62f..e0a1cf970 100644 --- a/plugins/User/__init__.py +++ b/plugins/User/__init__.py @@ -44,12 +44,13 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -import config -import plugin +from . import config +from . import plugin +from imp import reload reload(plugin) # In case we're being reloaded. if world.testing: - import test + from . import test Class = plugin.Class configure = config.configure diff --git a/plugins/Utilities/__init__.py b/plugins/Utilities/__init__.py index aa87ef57d..641cd996c 100644 --- a/plugins/Utilities/__init__.py +++ b/plugins/Utilities/__init__.py @@ -44,12 +44,13 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -import config -import plugin +from . import config +from . import plugin +from imp import reload reload(plugin) # In case we're being reloaded. if world.testing: - import test + from . import test Class = plugin.Class configure = config.configure diff --git a/plugins/Web/__init__.py b/plugins/Web/__init__.py index 68e4db1f7..c4eef6ff4 100644 --- a/plugins/Web/__init__.py +++ b/plugins/Web/__init__.py @@ -42,14 +42,15 @@ __author__ = supybot.authors.jemfinch # contributions. __contributors__ = {} -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 diff --git a/plugins/Web/plugin.py b/plugins/Web/plugin.py index 52dab893e..93ee0a776 100644 --- a/plugins/Web/plugin.py +++ b/plugins/Web/plugin.py @@ -35,7 +35,7 @@ import socket import supybot.conf as conf import supybot.utils as utils from supybot.commands import * -import supybot.minisix as minisix +import supybot.utils.minisix as minisix import supybot.plugins as plugins import supybot.commands as commands import supybot.ircutils as ircutils diff --git a/setup.py b/setup.py index 2d4ced598..63052c2a7 100644 --- a/setup.py +++ b/setup.py @@ -120,54 +120,6 @@ except ImportError as e: sys.stderr.write(textwrap.fill(s)) sys.stderr.write(os.linesep*2) sys.exit(-1) -try: - from distutils.command.build_py import build_py_2to3 - class build_py(build_py_2to3): - def run_2to3(self, files, options=None): - from distutils import log - from lib2to3.refactor import RefactoringTool, get_fixers_from_package - if not files: - return - - # Make this class local, to delay import of 2to3 - from lib2to3.refactor import RefactoringTool, get_fixers_from_package - class DistutilsRefactoringTool(RefactoringTool): - def refactor(self, files, *args, **kwargs): - self._total_files = len(files) - self._refactored_files = 0 - super(DistutilsRefactoringTool, self).refactor(files, - *args, **kwargs) - del self._total_files - del self._refactored_files - def refactor_file(self, filename, *args, **kwargs): - if self._total_files//10 != 0 and \ - self._refactored_files % (self._total_files//10) == 0: - print('Refactoring files: %i%% (%i on %i).' % - (ceil(self._refactored_files*100./self._total_files), - self._refactored_files, self._total_files)) - self._refactored_files += 1 - return super(DistutilsRefactoringTool, self).refactor_file( - filename, *args, **kwargs) - def log_error(self, msg, *args, **kw): - log.error(msg, *args) - - def log_message(self, msg, *args): - log.info(msg, *args) - - def log_debug(self, msg, *args): - log.debug(msg, *args) - - fixer_names = [ - 'fix_metaclass', - 'fix_numliterals', - ] - fixers = list(map(lambda x:'lib2to3.fixes.'+x, fixer_names)) - fixers += get_fixers_from_package('2to3') - r = DistutilsRefactoringTool(fixers, options=options) - r.refactor(files, write=True) -except ImportError: - # 2.x - from distutils.command.build_py import build_py if clean: @@ -209,12 +161,6 @@ for plugin in plugins: if os.path.exists(locales_path): package_data.update({locales_name: ['locales/'+s for s in os.listdir(locales_path)]}) - -try: - shutil.rmtree('2to3/__pycache__') -except OSError: - pass - setup( # Metadata name='limnoria', @@ -253,7 +199,6 @@ setup( 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', ], - cmdclass = {'build_py': build_py}, # Installation data packages=packages, diff --git a/src/__init__.py b/src/__init__.py index 055e7cc07..7916bc231 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -28,7 +28,7 @@ # POSSIBILITY OF SUCH DAMAGE. ### -import dynamicScope +from . import dynamicScope from . import utils diff --git a/src/callbacks.py b/src/callbacks.py index ae5a3efc0..6715410f5 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -37,13 +37,14 @@ import re import sys import copy import time -import shlex +from . import shlex import codecs import getopt import inspect -from . import (conf, ircdb, irclib, ircmsgs, ircutils, log, minisix, registry, +from . import (conf, ircdb, irclib, ircmsgs, ircutils, log, registry, utils, world) +from .utils import minisix from .utils.iter import any, all from .i18n import PluginInternationalization, internationalizeDocstring _ = PluginInternationalization() @@ -1132,11 +1133,12 @@ class BasePlugin(object): cb.log = log.getPluginLogger('%s.%s' % (self.name(),cb.name())) super(BasePlugin, self).__init__() -class SynchronizedAndFirewalled(log.MetaFirewall, utils.python.Synchronized): - pass # Necessary for the metaclass compatibility issue. +class MetaSynchronizedAndFirewalled(log.MetaFirewall, utils.python.MetaSynchronized): + pass +SynchronizedAndFirewalled = MetaSynchronizedAndFirewalled( + 'SynchronizedAndFirewalled', (), {}) -class Commands(BasePlugin): - __metaclass__ = SynchronizedAndFirewalled +class Commands(BasePlugin, SynchronizedAndFirewalled): __synchronized__ = ( '__call__', 'callCommand', diff --git a/src/cdb.py b/src/cdb.py index a96a43861..029281eb6 100644 --- a/src/cdb.py +++ b/src/cdb.py @@ -39,13 +39,14 @@ import sys import struct import os.path -from . import utils, minisix +from . import utils +from .utils import minisix def hash(s): """DJB's hash function for CDB.""" h = 5381 for c in s: - h = ((h + (h << 5)) ^ ord(c)) & 0xFFFFFFFFL + h = ((h + (h << 5)) ^ ord(c)) & minisix.L(0xFFFFFFFF) return h def unpack2Ints(s): diff --git a/src/commands.py b/src/commands.py index b49d29567..b494349d4 100644 --- a/src/commands.py +++ b/src/commands.py @@ -43,8 +43,9 @@ try: except ImportError: # Windows! resource = None -from . import callbacks, conf, ircdb, ircmsgs, ircutils, log, minisix, \ +from . import callbacks, conf, ircdb, ircmsgs, ircutils, log, \ utils, world +from .utils import minisix from .i18n import PluginInternationalization, internationalizeDocstring _ = PluginInternationalization() diff --git a/src/dbi.py b/src/dbi.py index f80870c13..89a1d8240 100644 --- a/src/dbi.py +++ b/src/dbi.py @@ -35,7 +35,8 @@ import os import csv import math -from . import cdb, minisix, utils +from . import cdb, utils +from .utils import minisix from .utils.iter import ilen class Error(Exception): diff --git a/src/drivers/Socket.py b/src/drivers/Socket.py index f7655da59..d1b10dc99 100644 --- a/src/drivers/Socket.py +++ b/src/drivers/Socket.py @@ -41,7 +41,8 @@ import errno import select import socket -from .. import (conf, drivers, log, minisix, schedule, utils, world) +from .. import (conf, drivers, log, schedule, utils, world) +from ..utils import minisix from ..utils.iter import imap from ..utils.str import decode_raw_line diff --git a/src/drivers/__init__.py b/src/drivers/__init__.py index 457c34cb0..c41913fa0 100644 --- a/src/drivers/__init__.py +++ b/src/drivers/__init__.py @@ -36,7 +36,8 @@ import sys import time import socket -from .. import conf, ircmsgs, log as supylog, minisix, utils +from .. import conf, ircmsgs, log as supylog, utils +from ..utils import minisix _drivers = {} _deadDrivers = [] diff --git a/src/gpg.py b/src/gpg.py index c384af2b4..44615d7bb 100644 --- a/src/gpg.py +++ b/src/gpg.py @@ -75,7 +75,7 @@ def loadKeyring(): path = os.path.abspath(conf.supybot.directories.data.dirize('GPGkeyring')) if not os.path.isdir(path): log.info('Creating directory %s' % path) - os.mkdir(path, 0700) + os.mkdir(path, 0o700) assert os.path.isdir(path) keyring = gnupg.GPG(gnupghome=path) loadKeyring() diff --git a/src/httpserver.py b/src/httpserver.py index 33b1a65a1..4769f999b 100644 --- a/src/httpserver.py +++ b/src/httpserver.py @@ -40,7 +40,7 @@ from threading import Thread import supybot.log as log import supybot.conf as conf import supybot.world as world -import supybot.minisix as minisix +import supybot.utils.minisix as minisix from supybot.i18n import PluginInternationalization _ = PluginInternationalization() @@ -262,10 +262,9 @@ class SupyHTTPRequestHandler(BaseHTTPRequestHandler): log.info('HTTP request: %s - %s' % (self.address_string(), format % args)) -class SupyHTTPServerCallback(object): +class SupyHTTPServerCallback(log.Firewalled): """This is a base class that should be overriden by any plugin that want to have a Web interface.""" - __metaclass__ = log.MetaFirewall __firewalled__ = {'doGet': None, 'doPost': None, 'doHead': None, diff --git a/src/ircdb.py b/src/ircdb.py index 6eb6d3424..28c92fb4e 100644 --- a/src/ircdb.py +++ b/src/ircdb.py @@ -33,7 +33,8 @@ import os import time import operator -from . import conf, ircutils, log, minisix, registry, unpreserve, utils, world +from . import conf, ircutils, log, registry, unpreserve, utils, world +from .utils import minisix def isCapability(capability): return len(capability.split(None, 1)) == 1 diff --git a/src/irclib.py b/src/irclib.py index 60d30cc7b..3fde80494 100644 --- a/src/irclib.py +++ b/src/irclib.py @@ -60,7 +60,7 @@ class IrcCommandDispatcher(object): return getattr(self, 'do' + command.capitalize(), None) -class IrcCallback(IrcCommandDispatcher): +class IrcCallback(IrcCommandDispatcher, log.Firewalled): """Base class for standard callbacks. Callbacks derived from this class should have methods of the form @@ -69,7 +69,6 @@ class IrcCallback(IrcCommandDispatcher): """ callAfter = () callBefore = () - __metaclass__ = log.MetaFirewall __firewalled__ = {'die': None, 'reset': None, '__call__': None, @@ -343,10 +342,9 @@ class ChannelState(utils.python.Object): return ret -class IrcState(IrcCommandDispatcher): +class IrcState(IrcCommandDispatcher, log.Firewalled): """Maintains state of the Irc connection. Should also become smarter. """ - __metaclass__ = log.MetaFirewall __firewalled__ = {'addMsg': None} def __init__(self, history=None, supported=None, nicksToHostmasks=None, channels=None, @@ -641,12 +639,11 @@ class IrcState(IrcCommandDispatcher): # 'queue', and 'state', in addition to the standard nick/user/ident attributes. ### _callbacks = [] -class Irc(IrcCommandDispatcher): +class Irc(IrcCommandDispatcher, log.Firewalled): """The base class for an IRC connection. Handles PING commands already. """ - __metaclass__ = log.MetaFirewall __firewalled__ = {'die': None, 'feedMsg': None, 'takeMsg': None,} diff --git a/src/ircmsgs.py b/src/ircmsgs.py index b6e64b6d8..ebeb2c79c 100644 --- a/src/ircmsgs.py +++ b/src/ircmsgs.py @@ -40,8 +40,9 @@ import sys import time import functools -from . import conf, ircutils, minisix, utils +from . import conf, ircutils, utils from .utils.iter import all +from .utils import minisix ### # IrcMsg class -- used for representing IRC messages acquired from a network. diff --git a/src/ircutils.py b/src/ircutils.py index c960e9a29..949cb2642 100644 --- a/src/ircutils.py +++ b/src/ircutils.py @@ -47,7 +47,7 @@ import textwrap import functools from . import utils -from . import minisix +from .utils import minisix from .version import version from .i18n import PluginInternationalization, internationalizeDocstring diff --git a/src/log.py b/src/log.py index f5332f760..487242c9d 100644 --- a/src/log.py +++ b/src/log.py @@ -37,7 +37,8 @@ import operator import textwrap import traceback -from . import ansi, conf, ircutils, minisix, registry, utils +from . import ansi, conf, ircutils, registry, utils +from .utils import minisix deadlyExceptions = [KeyboardInterrupt, SystemExit] @@ -182,12 +183,12 @@ conf.registerGlobalValue(conf.supybot.directories, 'log', _logDir = conf.supybot.directories.log() if not os.path.exists(_logDir): - os.mkdir(_logDir, 0755) + os.mkdir(_logDir, 0o755) pluginLogDir = os.path.join(_logDir, 'plugins') if not os.path.exists(pluginLogDir): - os.mkdir(pluginLogDir, 0755) + os.mkdir(pluginLogDir, 0o755) try: messagesLogFilename = os.path.join(_logDir, 'messages.log') @@ -394,6 +395,7 @@ class MetaFirewall(type): for attr in __firewalled__: firewalled[attr] = cls.getErrorHandler(__firewalled__, attr) updateFirewalled = classmethod(updateFirewalled) +Firewalled = MetaFirewall('Firewalled', (), {}) class PluginLogFilter(logging.Filter): diff --git a/src/questions.py b/src/questions.py index dfeaece9e..cd15e8b12 100644 --- a/src/questions.py +++ b/src/questions.py @@ -35,7 +35,8 @@ import sys import textwrap from getpass import getpass as getPass -from . import ansi, minisix, utils +from . import ansi, utils +from .utils import minisix from supybot.i18n import PluginInternationalization, internationalizeDocstring _ = PluginInternationalization() diff --git a/src/registry.py b/src/registry.py index d863d0330..23a95da89 100644 --- a/src/registry.py +++ b/src/registry.py @@ -37,7 +37,8 @@ import codecs import string import textwrap -from . import utils, i18n, minisix +from . import utils, i18n +from .utils import minisix _ = i18n.PluginInternationalization() def error(s): diff --git a/src/shlex.py b/src/shlex.py index d7e00909e..715fb6569 100644 --- a/src/shlex.py +++ b/src/shlex.py @@ -7,7 +7,7 @@ import os.path import sys -from . import minisix +from .utils import minisix __all__ = ["shlex"] diff --git a/src/test.py b/src/test.py index 98c487ccc..80bb67e33 100644 --- a/src/test.py +++ b/src/test.py @@ -39,7 +39,8 @@ import unittest import threading from . import (callbacks, conf, drivers, httpserver, i18n, ircdb, irclib, - ircmsgs, ircutils, log, minisix, plugin, registry, utils, world) + ircmsgs, ircutils, log, plugin, registry, utils, world) +from .utils import minisix if minisix.PY2: from httplib import HTTPConnection diff --git a/src/utils/__init__.py b/src/utils/__init__.py index 34943a3ce..39e5304c3 100644 --- a/src/utils/__init__.py +++ b/src/utils/__init__.py @@ -29,7 +29,7 @@ ### import sys -from .. import minisix +from . import minisix ### # csv.{join,split} -- useful functions that should exist. diff --git a/src/utils/error.py b/src/utils/error.py index 774ac339a..2373bb5c5 100644 --- a/src/utils/error.py +++ b/src/utils/error.py @@ -29,7 +29,7 @@ import os -import gen +from . import gen class Error(Exception): def __init__(self, msg, e=None): diff --git a/src/utils/gen.py b/src/utils/gen.py index 3dad5e08f..cd1a50690 100644 --- a/src/utils/gen.py +++ b/src/utils/gen.py @@ -46,7 +46,7 @@ from . import crypt from .str import format from .file import mktemp from .iter import imap -from .. import minisix +from . import minisix from supybot.i18n import PluginInternationalization _ = PluginInternationalization() diff --git a/src/utils/iter.py b/src/utils/iter.py index ad48f3fca..0661f9f32 100644 --- a/src/utils/iter.py +++ b/src/utils/iter.py @@ -34,7 +34,7 @@ import random from itertools import * -from .. import minisix +from . import minisix # For old plugins ifilter = filter diff --git a/src/minisix.py b/src/utils/minisix.py similarity index 98% rename from src/minisix.py rename to src/utils/minisix.py index 919783771..1470d5fd6 100644 --- a/src/minisix.py +++ b/src/utils/minisix.py @@ -44,6 +44,7 @@ if sys.version_info[0] >= 3: import queue u = lambda x:x + L = lambda x:x else: PY2 = True PY3 = False @@ -65,3 +66,4 @@ else: import Queue as queue u = lambda x:x.decode('utf8') + L = lambda x:long(x) diff --git a/src/utils/python.py b/src/utils/python.py index acd2cba7d..4db8c3f81 100644 --- a/src/utils/python.py +++ b/src/utils/python.py @@ -72,20 +72,20 @@ class Object(object): def __ne__(self, other): return not self == other -class Synchronized(type): +class MetaSynchronized(type): METHODS = '__synchronized__' - LOCK = '_Synchronized_rlock' + LOCK = '_MetaSynchronized_rlock' def __new__(cls, name, bases, dict): sync = set() for base in bases: - if hasattr(base, Synchronized.METHODS): - sync.update(getattr(base, Synchronized.METHODS)) - if Synchronized.METHODS in dict: - sync.update(dict[Synchronized.METHODS]) + if hasattr(base, MetaSynchronized.METHODS): + sync.update(getattr(base, MetaSynchronized.METHODS)) + if MetaSynchronized.METHODS in dict: + sync.update(dict[MetaSynchronized.METHODS]) if sync: def synchronized(f): def g(self, *args, **kwargs): - lock = getattr(self, Synchronized.LOCK) + lock = getattr(self, MetaSynchronized.LOCK) lock.acquire() try: f(self, *args, **kwargs) @@ -97,16 +97,17 @@ class Synchronized(type): dict[attr] = synchronized(dict[attr]) original__init__ = dict.get('__init__') def __init__(self, *args, **kwargs): - if not hasattr(self, Synchronized.LOCK): - setattr(self, Synchronized.LOCK, threading.RLock()) + if not hasattr(self, MetaSynchronized.LOCK): + setattr(self, MetaSynchronized.LOCK, threading.RLock()) if original__init__: original__init__(self, *args, **kwargs) else: # newclass is defined below. super(newclass, self).__init__(*args, **kwargs) dict['__init__'] = __init__ - newclass = super(Synchronized, cls).__new__(cls, name, bases, dict) + newclass = super(MetaSynchronized, cls).__new__(cls, name, bases, dict) return newclass +Synchronized = MetaSynchronized('Synchronized', (), {}) # Translate glob to regular expression, trimming the "match EOL" portion of # the regular expression. diff --git a/src/utils/str.py b/src/utils/str.py index 3aa4635af..24aa61706 100644 --- a/src/utils/str.py +++ b/src/utils/str.py @@ -39,7 +39,7 @@ import time import string import textwrap -from .. import minisix +from . import minisix from .iter import all, any from .structures import TwoWayDictionary @@ -574,7 +574,7 @@ def format(s, *args, **kwargs): elif char == 't': return timestamp(args.pop()) elif char == 'T': - from gen import timeElapsed + from .gen import timeElapsed return timeElapsed(args.pop()) elif char == 'u': import supybot.conf as conf diff --git a/src/utils/web.py b/src/utils/web.py index 10e6aafa3..ad2ab18bf 100644 --- a/src/utils/web.py +++ b/src/utils/web.py @@ -40,7 +40,7 @@ except AttributeError: pass from .str import normalizeWhitespace -from .. import minisix +from . import minisix if minisix.PY2: import urllib diff --git a/src/world.py b/src/world.py index bc2ea174e..6612bea57 100644 --- a/src/world.py +++ b/src/world.py @@ -42,7 +42,8 @@ import multiprocessing import re -from . import conf, drivers, ircutils, log, minisix, registry +from . import conf, drivers, ircutils, log, registry +from .utils import minisix startedAt = time.time() # Just in case it doesn't get set later. diff --git a/test/test_callbacks.py b/test/test_callbacks.py index 160f63b26..3384c74be 100644 --- a/test/test_callbacks.py +++ b/test/test_callbacks.py @@ -33,7 +33,7 @@ from supybot.test import * import supybot.conf as conf import supybot.utils as utils import supybot.ircmsgs as ircmsgs -import supybot.minisix as minisix +import supybot.utils.minisix as minisix import supybot.callbacks as callbacks tokenize = callbacks.tokenize diff --git a/test/test_commands.py b/test/test_commands.py index 475e2b10f..54eead35e 100644 --- a/test/test_commands.py +++ b/test/test_commands.py @@ -37,7 +37,7 @@ from supybot.commands import * import supybot.conf as conf import supybot.irclib as irclib import supybot.ircmsgs as ircmsgs -import supybot.minisix as minisix +import supybot.utils.minisix as minisix import supybot.callbacks as callbacks diff --git a/test/test_firewall.py b/test/test_firewall.py index 1d285021e..9becc3a1c 100644 --- a/test/test_firewall.py +++ b/test/test_firewall.py @@ -29,7 +29,7 @@ from supybot.test import * from supybot import log -import supybot.minisix as minisix +import supybot.utils.minisix as minisix class FirewallTestCase(SupyTestCase): def setUp(self): diff --git a/test/test_utils.py b/test/test_utils.py index 7da0ddff6..ce0c92c1f 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -35,7 +35,7 @@ import time import pickle import supybot.utils as utils from supybot.utils.structures import * -import supybot.minisix as minisix +import supybot.utils.minisix as minisix if sys.version_info[0] >= 0: xrange = range