mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-27 04:59:24 +01:00
core: remove references to plugins/protocols_folder (#259)
This commit is contained in:
parent
c58c4d4a9c
commit
bcc84b8618
@ -68,7 +68,7 @@ def load(irc, source, args):
|
||||
return
|
||||
log.info('(%s) Loading plugin %r for %s', irc.name, name, irc.getHostmask(source))
|
||||
try:
|
||||
world.plugins[name] = pl = utils.loadModuleFromFolder(name, world.plugins_folder)
|
||||
world.plugins[name] = pl = utils.loadPlugin(name)
|
||||
except ImportError as e:
|
||||
if str(e) == ('No module named %r' % name):
|
||||
log.exception('Failed to load plugin %r: The plugin could not be found.', name)
|
||||
|
2
pylink
2
pylink
@ -45,7 +45,7 @@ if __name__ == '__main__':
|
||||
# dynamically depending on which were configured.
|
||||
for plugin in to_load:
|
||||
try:
|
||||
world.plugins[plugin] = pl = utils.loadModuleFromFolder(plugin, world.plugins_folder)
|
||||
world.plugins[plugin] = pl = utils.loadPlugin(plugin)
|
||||
except (OSError, ImportError) as e:
|
||||
log.exception('Failed to load plugin %r: %s: %s', plugin, type(e).__name__, str(e))
|
||||
else:
|
||||
|
12
utils.py
12
utils.py
@ -13,6 +13,8 @@ import collections
|
||||
|
||||
from .log import log
|
||||
from . import world, conf
|
||||
# This is just so protocols and plugins are importable.
|
||||
from pylinkirc import protocols, plugins
|
||||
|
||||
class NotAuthenticatedError(Exception):
|
||||
"""
|
||||
@ -126,11 +128,17 @@ def loadModuleFromFolder(name, folder):
|
||||
m = importlib.machinery.SourceFileLoader(name, fullpath).load_module()
|
||||
return m
|
||||
|
||||
def getProtocolModule(protoname):
|
||||
def loadPlugin(name):
|
||||
"""
|
||||
Imports and returns the requested plugin.
|
||||
"""
|
||||
return importlib.import_module('pylinkirc.plugins.' + name)
|
||||
|
||||
def getProtocolModule(name):
|
||||
"""
|
||||
Imports and returns the protocol module requested.
|
||||
"""
|
||||
return loadModuleFromFolder(protoname, world.protocols_folder)
|
||||
return importlib.import_module('pylinkirc.protocols.' + name)
|
||||
|
||||
def getDatabaseName(dbname):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user