3
0
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:
James Lu 2016-07-02 23:57:20 -07:00
parent c58c4d4a9c
commit bcc84b8618
4 changed files with 12 additions and 7 deletions

View File

@ -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
View File

@ -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:

View File

@ -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):
"""

View File

@ -20,9 +20,6 @@ services = {}
started = threading.Event()
plugins_folder = os.path.join(os.getcwd(), 'plugins')
protocols_folder = os.path.join(os.getcwd(), 'protocols')
version = "<unknown>"
source = "https://github.com/GLolol/PyLink" # CHANGE THIS IF YOU'RE FORKING!!