Allow json for native module configs

This commit is contained in:
dpedu 2015-06-18 20:43:17 -07:00
parent a6afeab07d
commit f66f0b03a5
3 changed files with 11 additions and 6 deletions

View File

@ -2,7 +2,6 @@
import os
import sys
import logging
import yaml
from optparse import OptionParser
from pyircbot import PyIRCBot

View File

@ -8,7 +8,7 @@
import logging
import os
import yaml
from .pyircbot import PyIRCBot
class ModuleBase:
"""All modules will extend this class
@ -47,8 +47,8 @@ class ModuleBase:
def loadConfig(self):
"""Loads this module's config into self.config"""
configPath = self.bot.getConfigPath(self.moduleName)
if os.path.exists( configPath ):
self.config = yaml.load(open(configPath, 'r'))
if not configPath == None:
self.config = PyIRCBot.load(configPath)
def ondisable(self):
"""Called when the module should be disabled. Your module should do any sort

View File

@ -11,7 +11,6 @@ import time
import sys
from pyircbot.rpc import BotRPC
from pyircbot.irccore import IRCCore
from pyircbot import modulebase
import os.path
class PyIRCBot:
@ -291,7 +290,14 @@ class PyIRCBot:
:param moduleName: the module who's config file we want
: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 "
@staticmethod