From 0cc5865ba1e9f22565115460e0e5cd4a8b4e918f Mon Sep 17 00:00:00 2001 From: steffen123 Date: Mon, 23 Aug 2010 03:56:07 +0200 Subject: [PATCH] config: expand general section as discussed on ML, add defaults for it --- pyfpdb/Configuration.py | 16 ++++++++++++++++ pyfpdb/HUD_config.xml.example | 7 +++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py index b5afcf5a..980fc8e5 100755 --- a/pyfpdb/Configuration.py +++ b/pyfpdb/Configuration.py @@ -519,6 +519,20 @@ class General(dict): for (name, value) in node.attributes.items(): log.debug(_("config.general: adding %s = %s") % (name,value)) self[name] = value + + try: + self["version"]=int(self["version"]) + except KeyError: + self["version"]=0 + self["ui_language"]="system" + self["config_difficuly"]="expert" + + def get_defaults(self): + self["version"]=0 + self["ui_language"]="system" + self["config_difficuly"]="expert" + self["config_wrap_len"]="-1" + self["day_start"]="5" def __str__(self): s = "" @@ -703,6 +717,8 @@ class Config: self.emails = {} self.gui_cash_stats = GUICashStats() + if doc.getElementsByTagName("general") == []: + self.general.get_defaults() for gen_node in doc.getElementsByTagName("general"): self.general.add_elements(node=gen_node) # add/overwrite elements in self.general diff --git a/pyfpdb/HUD_config.xml.example b/pyfpdb/HUD_config.xml.example index c2a47419..977b6060 100644 --- a/pyfpdb/HUD_config.xml.example +++ b/pyfpdb/HUD_config.xml.example @@ -5,8 +5,11 @@ -