Allow json for native module configs
This commit is contained in:
parent
a6afeab07d
commit
f66f0b03a5
|
@ -2,7 +2,6 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
import yaml
|
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
from pyircbot import PyIRCBot
|
from pyircbot import PyIRCBot
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import yaml
|
from .pyircbot import PyIRCBot
|
||||||
|
|
||||||
class ModuleBase:
|
class ModuleBase:
|
||||||
"""All modules will extend this class
|
"""All modules will extend this class
|
||||||
|
@ -47,8 +47,8 @@ class ModuleBase:
|
||||||
def loadConfig(self):
|
def loadConfig(self):
|
||||||
"""Loads this module's config into self.config"""
|
"""Loads this module's config into self.config"""
|
||||||
configPath = self.bot.getConfigPath(self.moduleName)
|
configPath = self.bot.getConfigPath(self.moduleName)
|
||||||
if os.path.exists( configPath ):
|
if not configPath == None:
|
||||||
self.config = yaml.load(open(configPath, 'r'))
|
self.config = PyIRCBot.load(configPath)
|
||||||
|
|
||||||
def ondisable(self):
|
def ondisable(self):
|
||||||
"""Called when the module should be disabled. Your module should do any sort
|
"""Called when the module should be disabled. Your module should do any sort
|
||||||
|
|
|
@ -11,7 +11,6 @@ import time
|
||||||
import sys
|
import sys
|
||||||
from pyircbot.rpc import BotRPC
|
from pyircbot.rpc import BotRPC
|
||||||
from pyircbot.irccore import IRCCore
|
from pyircbot.irccore import IRCCore
|
||||||
from pyircbot import modulebase
|
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
class PyIRCBot:
|
class PyIRCBot:
|
||||||
|
@ -291,7 +290,14 @@ class PyIRCBot:
|
||||||
|
|
||||||
:param moduleName: the module who's config file we want
|
:param moduleName: the module who's config file we want
|
||||||
:type moduleName: str"""
|
:type moduleName: str"""
|
||||||
return "%s/config/%s.yml" % (self.botconfig["bot"]["datadir"], moduleName)
|
|
||||||
|
basepath = "%s/config/%s" % (self.botconfig["bot"]["datadir"], moduleName)
|
||||||
|
|
||||||
|
if os.path.exists("%s.yml"%basepath):
|
||||||
|
return "%s.yml"%basepath
|
||||||
|
elif os.path.exists("%s.json"%basepath):
|
||||||
|
return "%s.json"%basepath
|
||||||
|
return None
|
||||||
|
|
||||||
" Utility methods "
|
" Utility methods "
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
Loading…
Reference in New Issue