]>
code.delx.au - pymsnt/blob - src/xmlconfig.py
1 # Copyright 2004 James Bunton <james@delx.cjb.net>
2 # Licensed for distribution under the GPL version 2, check COPYING for details
12 def invalidError(text
):
19 # Find out where the config file is
20 configFile
= "../config.xml"
21 if(len(sys
.argv
) == 2):
22 configFile
= sys
.argv
[1]
24 # Check the file exists
25 if(not os
.path
.isfile(configFile
)):
26 print "Configuration file not found. You need to create a config.xml file in the PyMSNt directory."
30 root
= utils
.parseFile(configFile
)
32 # Store all the options in config
33 for el
in root
.elements():
38 # For config options like <ip>127.0.0.1</ip>
39 if(type(getattr(config
, tag
)) != str):
40 invalidError("Tag %s in your configuration file should be a boolean (ie, no cdata)." % (tag
))
41 setattr(config
, tag
, cdata
)
43 # For config options like <sessionGreeting/>
44 if(type(getattr(config
, tag
)) not in [bool, int]):
45 invalidError("Tag %s in your configuration file should be a string (ie, must have cdata)." % (tag
))
46 setattr(config
, tag
, True)
47 except AttributeError:
48 print "Tag %s in your configuration file is not a defined tag. Ignoring!" % (tag
)