]> code.delx.au - pymsnt/blobdiff - src/xmlconfig.py
Groupchat timeout is configurable.
[pymsnt] / src / xmlconfig.py
index 699042e4c9a75891123002034441fbf164f0dd81..ea3065520af91794143e9c6bccc8cf14823ad42a 100644 (file)
@@ -1,11 +1,10 @@
 # Copyright 2004-2005 James Bunton <james@delx.cjb.net>
 # Licensed for distribution under the GPL version 2, check COPYING for details
 
+from tlib import xmlw
 
-import sys
-import os
+import sys, os
 
-import utils
 import config
 
 
@@ -16,12 +15,7 @@ def invalidError(text):
        sys.exit(1)
 
 
-def reloadConfig():
-       # Find out where the config file is
-       configFile = config.configFile
-       if len(sys.argv) == 2:
-               configFile = sys.argv[1]
-
+def importFile(configFile):
        # Check the file exists
        if not os.path.isfile(configFile):
                print "Configuration file not found. You need to create a config.xml file in the PyMSNt directory."
@@ -29,7 +23,7 @@ def reloadConfig():
 
        # Get ourself a DOM
        try:
-               root = utils.parseFile(configFile)
+               root = xmlw.parseFile(configFile)
        except Exception, e:
                invalidError("Error parsing configuration file: " + str(e))
 
@@ -62,8 +56,16 @@ def reloadConfig():
                        print "Tag %s in your configuration file is not a defined tag. Ignoring!" % (tag)
        
 
-       # Apply some things immediately
-       from tlib.msn import msnw
-       msnw.GETALLAVATARS = config.getAllAvatars
+def importOptions(options):
+       for o in options:
+               if hasattr(config, o):
+                       setattr(config, o, options[0])
+               else:
+                       print "Option %s is not a defined option. Ignoring!" % (o)
 
+def reloadConfig(file=None, options=None):
+       if file:
+               importFile(file)
+       if options:
+               importOptions(options)