mirror of
https://github.com/jlu5/PyLink.git
synced 2025-02-18 14:30:42 +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
|
return
|
||||||
log.info('(%s) Loading plugin %r for %s', irc.name, name, irc.getHostmask(source))
|
log.info('(%s) Loading plugin %r for %s', irc.name, name, irc.getHostmask(source))
|
||||||
try:
|
try:
|
||||||
world.plugins[name] = pl = utils.loadModuleFromFolder(name, world.plugins_folder)
|
world.plugins[name] = pl = utils.loadPlugin(name)
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
if str(e) == ('No module named %r' % name):
|
if str(e) == ('No module named %r' % name):
|
||||||
log.exception('Failed to load plugin %r: The plugin could not be found.', 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.
|
# dynamically depending on which were configured.
|
||||||
for plugin in to_load:
|
for plugin in to_load:
|
||||||
try:
|
try:
|
||||||
world.plugins[plugin] = pl = utils.loadModuleFromFolder(plugin, world.plugins_folder)
|
world.plugins[plugin] = pl = utils.loadPlugin(plugin)
|
||||||
except (OSError, ImportError) as e:
|
except (OSError, ImportError) as e:
|
||||||
log.exception('Failed to load plugin %r: %s: %s', plugin, type(e).__name__, str(e))
|
log.exception('Failed to load plugin %r: %s: %s', plugin, type(e).__name__, str(e))
|
||||||
else:
|
else:
|
||||||
|
12
utils.py
12
utils.py
@ -13,6 +13,8 @@ import collections
|
|||||||
|
|
||||||
from .log import log
|
from .log import log
|
||||||
from . import world, conf
|
from . import world, conf
|
||||||
|
# This is just so protocols and plugins are importable.
|
||||||
|
from pylinkirc import protocols, plugins
|
||||||
|
|
||||||
class NotAuthenticatedError(Exception):
|
class NotAuthenticatedError(Exception):
|
||||||
"""
|
"""
|
||||||
@ -126,11 +128,17 @@ def loadModuleFromFolder(name, folder):
|
|||||||
m = importlib.machinery.SourceFileLoader(name, fullpath).load_module()
|
m = importlib.machinery.SourceFileLoader(name, fullpath).load_module()
|
||||||
return m
|
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.
|
Imports and returns the protocol module requested.
|
||||||
"""
|
"""
|
||||||
return loadModuleFromFolder(protoname, world.protocols_folder)
|
return importlib.import_module('pylinkirc.protocols.' + name)
|
||||||
|
|
||||||
def getDatabaseName(dbname):
|
def getDatabaseName(dbname):
|
||||||
"""
|
"""
|
||||||
|
3
world.py
3
world.py
@ -20,9 +20,6 @@ services = {}
|
|||||||
|
|
||||||
started = threading.Event()
|
started = threading.Event()
|
||||||
|
|
||||||
plugins_folder = os.path.join(os.getcwd(), 'plugins')
|
|
||||||
protocols_folder = os.path.join(os.getcwd(), 'protocols')
|
|
||||||
|
|
||||||
version = "<unknown>"
|
version = "<unknown>"
|
||||||
source = "https://github.com/GLolol/PyLink" # CHANGE THIS IF YOU'RE FORKING!!
|
source = "https://github.com/GLolol/PyLink" # CHANGE THIS IF YOU'RE FORKING!!
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user