Started project refresh

This commit is contained in:
Luke Rogers 2013-10-01 19:12:41 +13:00
parent dd40b71252
commit 28cb06c84b
4 changed files with 62 additions and 35 deletions

View file

@ -1,27 +1,17 @@
import inspect
import json
import os
def save(conf):
json.dump(conf, open('config', 'w'), sort_keys=True, indent=2)
class Config(dict):
def __init__(self, name, *args, **kwargs):
self.path = os.path.abspath(name)
self.update(*args, **kwargs)
if not os.path.exists('config'):
print "Please rename 'config.default' to 'config' to set up your bot!"
print "For help, see http://git.io/cloudbotirc"
print "Thank you for using CloudBot!"
sys.exit()
def reload(self):
with open(self.path) as f:
self = json.load(f)
print self
def config():
# reload config from file if file has changed
config_mtime = os.stat('config').st_mtime
if bot._config_mtime != config_mtime:
try:
bot.config = json.load(open('config'))
bot._config_mtime = config_mtime
except ValueError, e:
print 'error: malformed config', e
bot._config_mtime = 0
def save(self):
pass