3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-01 01:09:22 +01:00

Rename utils.getProtoModule => utils.getProtocolModule

This commit is contained in:
James Lu 2015-12-24 17:33:49 -08:00
parent 2391918deb
commit 9a81a2ba1f
3 changed files with 12 additions and 4 deletions

View File

@ -199,7 +199,7 @@ def rehash(irc, source, args):
for network, sdata in new_conf['servers'].items(): for network, sdata in new_conf['servers'].items():
# New server was added. Connect them if not already connected. # New server was added. Connect them if not already connected.
if network not in world.networkobjects: if network not in world.networkobjects:
proto = utils.getProtoModule(sdata['protocol']) proto = utils.getProtocolModule(sdata['protocol'])
world.networkobjects[network] = classes.Irc(network, proto, new_conf) world.networkobjects[network] = classes.Irc(network, proto, new_conf)
irc.reply("Done.") irc.reply("Done.")

12
pylink
View File

@ -39,10 +39,18 @@ if __name__ == '__main__':
log.debug('Calling main() function of plugin %r', pl) log.debug('Calling main() function of plugin %r', pl)
pl.main() pl.main()
for network in conf.conf['servers']: # Initialize all the networks one by one
proto = utils.getProtoModule(conf.conf['servers'][network]['protocol']) for network, sdata in conf.conf['servers'].items():
protoname = sdata['protocol']
# Fetch the correct protocol module
proto = utils.getProtocolModule(protoname)
world.networkobjects[network] = irc = classes.Irc(network, proto, conf.conf) world.networkobjects[network] = irc = classes.Irc(network, proto, conf.conf)
# Call coreplugin's initialization method
log.debug('Calling main() function of coreplugin on network %s', irc.name) log.debug('Calling main() function of coreplugin on network %s', irc.name)
coreplugin.main(irc) coreplugin.main(irc)
world.started.set() world.started.set()
log.info("loaded plugins: %s", world.plugins) log.info("loaded plugins: %s", world.plugins)

View File

@ -519,7 +519,7 @@ 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 getProtoModule(protoname): def getProtocolModule(protoname):
"""Imports and returns the protocol module requested.""" """Imports and returns the protocol module requested."""
return loadModuleFromFolder(protoname, world.protocols_folder) return loadModuleFromFolder(protoname, world.protocols_folder)