From 9ab908759adea950bb525a1ad262953c22fbd2ce Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sun, 26 Jan 2020 11:22:59 +0100 Subject: [PATCH] Use importlib instead of imp. importlib is deprecated. --- plugins/Admin/__init__.py | 2 +- plugins/Aka/__init__.py | 4 ++-- plugins/Alias/__init__.py | 2 +- plugins/Anonymous/__init__.py | 2 +- plugins/AutoMode/__init__.py | 2 +- plugins/BadWords/__init__.py | 2 +- plugins/Channel/__init__.py | 2 +- plugins/ChannelLogger/__init__.py | 2 +- plugins/ChannelStats/__init__.py | 2 +- plugins/Conditional/__init__.py | 2 +- plugins/Config/__init__.py | 2 +- plugins/Ctcp/__init__.py | 2 +- plugins/Debug/__init__.py | 4 ++-- plugins/Dict/__init__.py | 2 +- plugins/Dunno/__init__.py | 2 +- plugins/Factoids/__init__.py | 2 +- plugins/Filter/__init__.py | 2 +- plugins/Format/__init__.py | 2 +- plugins/GPG/__init__.py | 4 ++-- plugins/Games/__init__.py | 2 +- plugins/Google/__init__.py | 2 +- plugins/Hashes/__init__.py | 2 +- plugins/Herald/__init__.py | 2 +- plugins/Internet/__init__.py | 2 +- plugins/Karma/__init__.py | 2 +- plugins/Lart/__init__.py | 2 +- plugins/Later/__init__.py | 2 +- plugins/Limiter/__init__.py | 2 +- plugins/Math/__init__.py | 2 +- plugins/MessageParser/__init__.py | 2 +- plugins/Misc/__init__.py | 2 +- plugins/Misc/plugin.py | 7 ------- plugins/MoobotFactoids/__init__.py | 2 +- plugins/Network/__init__.py | 2 +- plugins/News/__init__.py | 2 +- plugins/NickAuth/__init__.py | 2 +- plugins/NickCapture/__init__.py | 2 +- plugins/Nickometer/__init__.py | 2 +- plugins/Note/__init__.py | 2 +- plugins/Owner/__init__.py | 2 +- plugins/Owner/plugin.py | 2 +- plugins/Plugin/__init__.py | 2 +- plugins/PluginDownloader/__init__.py | 2 +- plugins/PluginDownloader/plugin.py | 2 +- plugins/Praise/__init__.py | 2 +- plugins/Protector/__init__.py | 2 +- plugins/Quote/__init__.py | 2 +- plugins/QuoteGrabs/__init__.py | 2 +- plugins/RSS/__init__.py | 2 +- plugins/Relay/__init__.py | 2 +- plugins/Reply/__init__.py | 2 +- plugins/Scheduler/__init__.py | 2 +- plugins/Seen/__init__.py | 2 +- plugins/Services/__init__.py | 2 +- plugins/ShrinkUrl/__init__.py | 2 +- plugins/Status/__init__.py | 2 +- plugins/String/__init__.py | 2 +- plugins/Success/__init__.py | 2 +- plugins/Time/__init__.py | 2 +- plugins/Todo/__init__.py | 2 +- plugins/Topic/__init__.py | 2 +- plugins/URL/__init__.py | 2 +- plugins/Unix/__init__.py | 2 +- plugins/User/__init__.py | 2 +- plugins/Utilities/__init__.py | 2 +- plugins/Web/__init__.py | 2 +- src/plugin.py | 23 +++++++++++++++++++---- 67 files changed, 87 insertions(+), 79 deletions(-) diff --git a/plugins/Admin/__init__.py b/plugins/Admin/__init__.py index 881b152c1..390f17af6 100644 --- a/plugins/Admin/__init__.py +++ b/plugins/Admin/__init__.py @@ -48,7 +48,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib import reload reload(plugin) # In case we're being reloaded. if world.testing: diff --git a/plugins/Aka/__init__.py b/plugins/Aka/__init__.py index 64c4b8603..93eef67a0 100644 --- a/plugins/Aka/__init__.py +++ b/plugins/Aka/__init__.py @@ -53,8 +53,8 @@ __url__ = '' # 'http://supybot.com/Members/yourname/Aka/download' from . import config from . import plugin -from imp import reload -from imp import reload +from importlib import reload +from importlib import reload # In case we're being reloaded. reload(config) reload(plugin) diff --git a/plugins/Alias/__init__.py b/plugins/Alias/__init__.py index dc840fedf..1b0483b13 100644 --- a/plugins/Alias/__init__.py +++ b/plugins/Alias/__init__.py @@ -48,7 +48,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Anonymous/__init__.py b/plugins/Anonymous/__init__.py index 1d38eac36..f6a84e28b 100644 --- a/plugins/Anonymous/__init__.py +++ b/plugins/Anonymous/__init__.py @@ -47,7 +47,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/AutoMode/__init__.py b/plugins/AutoMode/__init__.py index 7ad0a9ad5..59c6e7373 100644 --- a/plugins/AutoMode/__init__.py +++ b/plugins/AutoMode/__init__.py @@ -49,7 +49,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/BadWords/__init__.py b/plugins/BadWords/__init__.py index 4a95f28a9..f4da833c8 100644 --- a/plugins/BadWords/__init__.py +++ b/plugins/BadWords/__init__.py @@ -48,7 +48,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Channel/__init__.py b/plugins/Channel/__init__.py index 88063cd59..436bcd421 100644 --- a/plugins/Channel/__init__.py +++ b/plugins/Channel/__init__.py @@ -50,7 +50,7 @@ __contributors__ = { from . import config from . import plugin -from imp import reload +from importlib import reload reload(plugin) # In case we're being reloaded. if world.testing: diff --git a/plugins/ChannelLogger/__init__.py b/plugins/ChannelLogger/__init__.py index 03ffa3893..dd8f2de18 100644 --- a/plugins/ChannelLogger/__init__.py +++ b/plugins/ChannelLogger/__init__.py @@ -47,7 +47,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/ChannelStats/__init__.py b/plugins/ChannelStats/__init__.py index 13a814564..75e6ab814 100644 --- a/plugins/ChannelStats/__init__.py +++ b/plugins/ChannelStats/__init__.py @@ -49,7 +49,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Conditional/__init__.py b/plugins/Conditional/__init__.py index 612afc72f..2b1c1e226 100644 --- a/plugins/Conditional/__init__.py +++ b/plugins/Conditional/__init__.py @@ -53,7 +53,7 @@ __url__ = '' # 'http://supybot.com/Members/yourname/Conditional/download' from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Config/__init__.py b/plugins/Config/__init__.py index 5adf94373..06520cf73 100644 --- a/plugins/Config/__init__.py +++ b/plugins/Config/__init__.py @@ -47,7 +47,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib import reload reload(plugin) # In case we're being reloaded. if world.testing: diff --git a/plugins/Ctcp/__init__.py b/plugins/Ctcp/__init__.py index 0cdcfca59..49b6cdcf4 100644 --- a/plugins/Ctcp/__init__.py +++ b/plugins/Ctcp/__init__.py @@ -46,7 +46,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Debug/__init__.py b/plugins/Debug/__init__.py index 7413fdd1a..934058ce0 100644 --- a/plugins/Debug/__init__.py +++ b/plugins/Debug/__init__.py @@ -47,9 +47,9 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib import reload if version_info[0] >= 3: - from imp import reload + from importlib import reload reload(plugin) # In case we're being reloaded. if world.testing: diff --git a/plugins/Dict/__init__.py b/plugins/Dict/__init__.py index 062daaf9d..f03080e20 100644 --- a/plugins/Dict/__init__.py +++ b/plugins/Dict/__init__.py @@ -47,7 +47,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib import reload from .local import dictclient reload(plugin) # In case we're being reloaded. reload(dictclient) diff --git a/plugins/Dunno/__init__.py b/plugins/Dunno/__init__.py index 439f5d58a..72fe4c873 100644 --- a/plugins/Dunno/__init__.py +++ b/plugins/Dunno/__init__.py @@ -51,7 +51,7 @@ __contributors__ = { from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Factoids/__init__.py b/plugins/Factoids/__init__.py index 50df45d7a..f2c093945 100644 --- a/plugins/Factoids/__init__.py +++ b/plugins/Factoids/__init__.py @@ -51,7 +51,7 @@ __url__ = '' # 'http://supybot.com/Members/yourname/Factoids/download' from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Filter/__init__.py b/plugins/Filter/__init__.py index 4d81de7fc..a470e3bfd 100644 --- a/plugins/Filter/__init__.py +++ b/plugins/Filter/__init__.py @@ -48,7 +48,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib import reload reload(plugin) # In case we're being reloaded. if world.testing: diff --git a/plugins/Format/__init__.py b/plugins/Format/__init__.py index c693e99c4..7367efc4e 100644 --- a/plugins/Format/__init__.py +++ b/plugins/Format/__init__.py @@ -47,7 +47,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib import reload reload(plugin) # In case we're being reloaded. if world.testing: diff --git a/plugins/GPG/__init__.py b/plugins/GPG/__init__.py index 53a8f57fe..cf7f2e2f5 100644 --- a/plugins/GPG/__init__.py +++ b/plugins/GPG/__init__.py @@ -51,8 +51,8 @@ __url__ = '' from . import config from . import plugin -from imp import reload -from imp import reload +from importlib import reload +from importlib import reload # In case we're being reloaded. reload(config) reload(plugin) diff --git a/plugins/Games/__init__.py b/plugins/Games/__init__.py index b40955326..b6539076f 100644 --- a/plugins/Games/__init__.py +++ b/plugins/Games/__init__.py @@ -47,7 +47,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Google/__init__.py b/plugins/Google/__init__.py index 9af164d2f..47afdd3d3 100644 --- a/plugins/Google/__init__.py +++ b/plugins/Google/__init__.py @@ -47,7 +47,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Hashes/__init__.py b/plugins/Hashes/__init__.py index fb242f6a7..da342c05c 100644 --- a/plugins/Hashes/__init__.py +++ b/plugins/Hashes/__init__.py @@ -47,7 +47,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Herald/__init__.py b/plugins/Herald/__init__.py index f71e37f40..043b1fc84 100644 --- a/plugins/Herald/__init__.py +++ b/plugins/Herald/__init__.py @@ -48,7 +48,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib import reload reload(plugin) # In case we're being reloaded. if world.testing: diff --git a/plugins/Internet/__init__.py b/plugins/Internet/__init__.py index 825fa4999..6789c781d 100644 --- a/plugins/Internet/__init__.py +++ b/plugins/Internet/__init__.py @@ -47,7 +47,7 @@ __contributors__ = {supybot.authors.jamessan: ['whois']} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Karma/__init__.py b/plugins/Karma/__init__.py index 04990b4ad..8f9f3318d 100644 --- a/plugins/Karma/__init__.py +++ b/plugins/Karma/__init__.py @@ -47,7 +47,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Lart/__init__.py b/plugins/Lart/__init__.py index c0fae360f..117d37a8c 100644 --- a/plugins/Lart/__init__.py +++ b/plugins/Lart/__init__.py @@ -47,7 +47,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Later/__init__.py b/plugins/Later/__init__.py index a5fe77434..95f331b95 100644 --- a/plugins/Later/__init__.py +++ b/plugins/Later/__init__.py @@ -49,7 +49,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Limiter/__init__.py b/plugins/Limiter/__init__.py index d41398132..0540a6b6e 100644 --- a/plugins/Limiter/__init__.py +++ b/plugins/Limiter/__init__.py @@ -47,7 +47,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Math/__init__.py b/plugins/Math/__init__.py index ea8c71818..541fc232a 100644 --- a/plugins/Math/__init__.py +++ b/plugins/Math/__init__.py @@ -47,7 +47,7 @@ __contributors__ = {supybot.Author('Keith Jones', 'kmj', ''): ['convert']} from . import config from . import plugin -from imp import reload +from importlib import reload from .local import convertcore reload(plugin) # In case we're being reloaded. reload(convertcore) diff --git a/plugins/MessageParser/__init__.py b/plugins/MessageParser/__init__.py index 877731588..34cdcd46b 100644 --- a/plugins/MessageParser/__init__.py +++ b/plugins/MessageParser/__init__.py @@ -52,7 +52,7 @@ __url__ = '' from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Misc/__init__.py b/plugins/Misc/__init__.py index f0c4c327e..d48519d92 100644 --- a/plugins/Misc/__init__.py +++ b/plugins/Misc/__init__.py @@ -47,7 +47,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib import reload reload(plugin) # In case we're being reloaded. if world.testing: diff --git a/plugins/Misc/plugin.py b/plugins/Misc/plugin.py index 89843353b..02b1ff9ab 100644 --- a/plugins/Misc/plugin.py +++ b/plugins/Misc/plugin.py @@ -30,7 +30,6 @@ import re import os -import imp import sys import json import time @@ -58,12 +57,6 @@ _ = PluginInternationalization('Misc') if minisix.PY2: from itertools import ifilter as filter -def get_suffix(file): - for suffix in imp.get_suffixes(): - if file[-len(suffix[0]):] == suffix[0]: - return suffix - return None - def getPluginsInDirectory(directory): # get modules in a given directory plugins = [] diff --git a/plugins/MoobotFactoids/__init__.py b/plugins/MoobotFactoids/__init__.py index 157710545..562d4b9e3 100644 --- a/plugins/MoobotFactoids/__init__.py +++ b/plugins/MoobotFactoids/__init__.py @@ -49,7 +49,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Network/__init__.py b/plugins/Network/__init__.py index 669668f52..da50cd43c 100644 --- a/plugins/Network/__init__.py +++ b/plugins/Network/__init__.py @@ -48,7 +48,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib import reload reload(plugin) # In case we're being reloaded. if world.testing: diff --git a/plugins/News/__init__.py b/plugins/News/__init__.py index 6d54da603..25842ae79 100644 --- a/plugins/News/__init__.py +++ b/plugins/News/__init__.py @@ -51,7 +51,7 @@ __url__ = '' # 'http://supybot.com/Members/yourname/News/download' from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/NickAuth/__init__.py b/plugins/NickAuth/__init__.py index e696c90c3..b008cb36a 100644 --- a/plugins/NickAuth/__init__.py +++ b/plugins/NickAuth/__init__.py @@ -51,7 +51,7 @@ __url__ = '' from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/NickCapture/__init__.py b/plugins/NickCapture/__init__.py index 1846b3af0..f93024774 100644 --- a/plugins/NickCapture/__init__.py +++ b/plugins/NickCapture/__init__.py @@ -48,7 +48,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Nickometer/__init__.py b/plugins/Nickometer/__init__.py index 4bec93127..1f336e4c1 100644 --- a/plugins/Nickometer/__init__.py +++ b/plugins/Nickometer/__init__.py @@ -67,7 +67,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Note/__init__.py b/plugins/Note/__init__.py index 009817e42..e89db1245 100644 --- a/plugins/Note/__init__.py +++ b/plugins/Note/__init__.py @@ -48,7 +48,7 @@ __contributors__ = { supybot.authors.inkedmn: ['Original implementation.'] } from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Owner/__init__.py b/plugins/Owner/__init__.py index 84ce24d56..da4d15b44 100644 --- a/plugins/Owner/__init__.py +++ b/plugins/Owner/__init__.py @@ -48,7 +48,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib import reload reload(plugin) # In case we're being reloaded. if world.testing: diff --git a/plugins/Owner/plugin.py b/plugins/Owner/plugin.py index 3cd05f658..65f768cca 100644 --- a/plugins/Owner/plugin.py +++ b/plugins/Owner/plugin.py @@ -478,7 +478,7 @@ class Owner(callbacks.Plugin): if hasattr(module, 'reload') and 'x' in locals(): module.reload(x) if hasattr(module, 'config'): - from imp import reload + from importlib import reload reload(module.config) for callback in callbacks: callback.die() diff --git a/plugins/Plugin/__init__.py b/plugins/Plugin/__init__.py index a05bcfa90..fa09cee2d 100644 --- a/plugins/Plugin/__init__.py +++ b/plugins/Plugin/__init__.py @@ -49,7 +49,7 @@ __contributors__ = { from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/PluginDownloader/__init__.py b/plugins/PluginDownloader/__init__.py index 7f84a9d57..e1b5af5b4 100644 --- a/plugins/PluginDownloader/__init__.py +++ b/plugins/PluginDownloader/__init__.py @@ -52,7 +52,7 @@ __url__ = '' # 'http://supybot.com/Members/yourname/PluginDownloader/download' from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/PluginDownloader/plugin.py b/plugins/PluginDownloader/plugin.py index ebcd10839..93375f77c 100644 --- a/plugins/PluginDownloader/plugin.py +++ b/plugins/PluginDownloader/plugin.py @@ -147,7 +147,7 @@ class GithubRepository(GitRepository): reload_imported = True elif not reload_imported and \ b'reload(' in line: - fd.write(b'from imp import reload\n') + fd.write(b'from importlib import reload\n') reload_imported = True fd.write(line) if newFileName.endswith('__init__.py'): diff --git a/plugins/Praise/__init__.py b/plugins/Praise/__init__.py index 838879125..fdad72492 100644 --- a/plugins/Praise/__init__.py +++ b/plugins/Praise/__init__.py @@ -47,7 +47,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Protector/__init__.py b/plugins/Protector/__init__.py index 26fbad56f..52afe71cf 100644 --- a/plugins/Protector/__init__.py +++ b/plugins/Protector/__init__.py @@ -48,7 +48,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Quote/__init__.py b/plugins/Quote/__init__.py index b265f754b..2a116eabc 100644 --- a/plugins/Quote/__init__.py +++ b/plugins/Quote/__init__.py @@ -47,7 +47,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/QuoteGrabs/__init__.py b/plugins/QuoteGrabs/__init__.py index 095ebd2ba..b52a5217d 100644 --- a/plugins/QuoteGrabs/__init__.py +++ b/plugins/QuoteGrabs/__init__.py @@ -51,7 +51,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib import reload reload(plugin) # In case we're being reloaded. if world.testing: diff --git a/plugins/RSS/__init__.py b/plugins/RSS/__init__.py index f8a4bd924..cf452a836 100644 --- a/plugins/RSS/__init__.py +++ b/plugins/RSS/__init__.py @@ -47,7 +47,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Relay/__init__.py b/plugins/Relay/__init__.py index 575804bfd..f7efc2d70 100644 --- a/plugins/Relay/__init__.py +++ b/plugins/Relay/__init__.py @@ -47,7 +47,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Reply/__init__.py b/plugins/Reply/__init__.py index 8ca442a87..5e68fda1c 100644 --- a/plugins/Reply/__init__.py +++ b/plugins/Reply/__init__.py @@ -48,7 +48,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Scheduler/__init__.py b/plugins/Scheduler/__init__.py index 48cb471e0..4996dc052 100644 --- a/plugins/Scheduler/__init__.py +++ b/plugins/Scheduler/__init__.py @@ -48,7 +48,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Seen/__init__.py b/plugins/Seen/__init__.py index 53a94bf96..5e5d9f6e8 100644 --- a/plugins/Seen/__init__.py +++ b/plugins/Seen/__init__.py @@ -47,7 +47,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Services/__init__.py b/plugins/Services/__init__.py index 759fd302c..c8c4e602b 100644 --- a/plugins/Services/__init__.py +++ b/plugins/Services/__init__.py @@ -47,7 +47,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/ShrinkUrl/__init__.py b/plugins/ShrinkUrl/__init__.py index 019d83e71..55fd91c02 100644 --- a/plugins/ShrinkUrl/__init__.py +++ b/plugins/ShrinkUrl/__init__.py @@ -47,7 +47,7 @@ __contributors__ = {supybot.authors.jamessan: ['xrl.us support', from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Status/__init__.py b/plugins/Status/__init__.py index 35236e3c1..511e079cb 100644 --- a/plugins/Status/__init__.py +++ b/plugins/Status/__init__.py @@ -48,7 +48,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib import reload reload(plugin) # In case we're being reloaded. if world.testing: diff --git a/plugins/String/__init__.py b/plugins/String/__init__.py index aebbd7382..f69fbd1d8 100644 --- a/plugins/String/__init__.py +++ b/plugins/String/__init__.py @@ -47,7 +47,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Success/__init__.py b/plugins/Success/__init__.py index 8b2a3b262..50eb7d55c 100644 --- a/plugins/Success/__init__.py +++ b/plugins/Success/__init__.py @@ -48,7 +48,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Time/__init__.py b/plugins/Time/__init__.py index e9568edb6..8dc0c6c51 100644 --- a/plugins/Time/__init__.py +++ b/plugins/Time/__init__.py @@ -50,7 +50,7 @@ __contributors__ = {supybot.authors.progval: ['tztime'], from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Todo/__init__.py b/plugins/Todo/__init__.py index fa5e11af7..53be38fd5 100644 --- a/plugins/Todo/__init__.py +++ b/plugins/Todo/__init__.py @@ -48,7 +48,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Topic/__init__.py b/plugins/Topic/__init__.py index 7f4b6b7f3..b6c4b18b6 100644 --- a/plugins/Topic/__init__.py +++ b/plugins/Topic/__init__.py @@ -47,7 +47,7 @@ __contributors__ = { supybot.authors.stepnem: ['persistence support'] } from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/URL/__init__.py b/plugins/URL/__init__.py index 47751cd50..503e93719 100644 --- a/plugins/URL/__init__.py +++ b/plugins/URL/__init__.py @@ -49,7 +49,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/Unix/__init__.py b/plugins/Unix/__init__.py index 64833fa79..55b8eee25 100644 --- a/plugins/Unix/__init__.py +++ b/plugins/Unix/__init__.py @@ -50,7 +50,7 @@ __url__ = '' # 'http://supybot.com/Members/yourname/Unix/download' from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/plugins/User/__init__.py b/plugins/User/__init__.py index 929e56250..e1cbc93b8 100644 --- a/plugins/User/__init__.py +++ b/plugins/User/__init__.py @@ -47,7 +47,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib import reload reload(plugin) # In case we're being reloaded. if world.testing: diff --git a/plugins/Utilities/__init__.py b/plugins/Utilities/__init__.py index 205cc8a88..7e061946f 100644 --- a/plugins/Utilities/__init__.py +++ b/plugins/Utilities/__init__.py @@ -47,7 +47,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib import reload reload(plugin) # In case we're being reloaded. if world.testing: diff --git a/plugins/Web/__init__.py b/plugins/Web/__init__.py index 791f26120..94a69177d 100644 --- a/plugins/Web/__init__.py +++ b/plugins/Web/__init__.py @@ -45,7 +45,7 @@ __contributors__ = {} from . import config from . import plugin -from imp import reload +from importlib 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! diff --git a/src/plugin.py b/src/plugin.py index 4f89d7153..8821bbd4c 100644 --- a/src/plugin.py +++ b/src/plugin.py @@ -28,11 +28,15 @@ ### import os +import re import sys -import imp import os.path import linecache -import re +import importlib.util + +if not hasattr(importlib.util, 'module_from_spec'): + # Python < 3.5 + import imp from . import callbacks, conf, log, registry @@ -60,9 +64,20 @@ def loadPluginModule(name, ignoreDeprecation=False): name = matched_names[0] else: raise ImportError(name) - moduleInfo = imp.find_module(name, pluginDirs) + try: - module = imp.load_module(name, *moduleInfo) + if hasattr(importlib.util, 'module_from_spec'): + # Python >= 3.5 + spec = importlib.machinery.PathFinder.find_spec(name, pluginDirs) + if spec is None: + assert ImportError(name) + module = importlib.util.module_from_spec(spec) + sys.modules[module.__name__] = module + spec.loader.exec_module(module) + else: + # Python < 3.5 + moduleInfo = imp.find_module(name, pluginDirs) + module = imp.load_module(name, *moduleInfo) except: sys.modules.pop(name, None) keys = list(sys.modules.keys())