diff options
author | Yann Leboulanger <asterix@lagaule.org> | 2004-01-24 23:32:51 +0300 |
---|---|---|
committer | Yann Leboulanger <asterix@lagaule.org> | 2004-01-24 23:32:51 +0300 |
commit | f913e4cd0e65a7dc916bf2294d6dd148bd60530e (patch) | |
tree | 33ed0a44b914e0f4997fb73a32ef311ad5f327b8 /common | |
parent | b2ec388e4bf936ad6e35ab4f9457d71d7ae6c498 (diff) |
- new configuration File management
- bugfix : message from unknown personne
Diffstat (limited to 'common')
-rw-r--r-- | common/hub.py | 1 | ||||
-rw-r--r-- | common/optparser.py | 35 | ||||
-rw-r--r-- | common/plugin.py | 1 | ||||
-rw-r--r-- | common/thread.py | 1 |
4 files changed, 26 insertions, 12 deletions
diff --git a/common/hub.py b/common/hub.py index b556d89ff..6bfb47231 100644 --- a/common/hub.py +++ b/common/hub.py @@ -4,7 +4,6 @@ ## Gajim Team: ## - Yann Le Boulanger <asterix@crans.org> ## - Vincent Hanquez <tab@tuxfamily.org> -## - David Ferlier <david@yazzy.org> ## ## Copyright (C) 2003 Gajim Team ## diff --git a/common/optparser.py b/common/optparser.py index b3812938e..08f86f891 100644 --- a/common/optparser.py +++ b/common/optparser.py @@ -4,7 +4,6 @@ ## Gajim Team: ## - Yann Le Boulanger <asterix@crans.org> ## - Vincent Hanquez <tab@tuxfamily.org> -## - David Ferlier <david@yazzy.org> ## ## Copyright (C) 2003 Gajim Team ## @@ -18,9 +17,7 @@ ## GNU General Public License for more details. ## -import ConfigParser -import logging -import os +import ConfigParser, logging, os, string log = logging.getLogger('common.options') @@ -28,6 +25,7 @@ class OptionsParser(ConfigParser.ConfigParser): def __init__(self, fname): ConfigParser.ConfigParser.__init__(self) self.__fname = os.path.expanduser(fname) + self.tab = {} # END __init__ def parseCfgFile(self): @@ -41,10 +39,19 @@ class OptionsParser(ConfigParser.ConfigParser): self.__sections = self.sections() for section in self.__sections: + self.tab[section] = {} for option in self.options(section): value = self.get(section, option, 1) - setattr(self, str(section) + '_' + \ - str(option), value) + #convert to int options than can be + try: + i = string.atoi(value) + except ValueError: + self.tab[section][option] = value + else: + self.tab[section][option] = i + +# setattr(self, str(section) + '_' + \ +# str(option), value) # END parseCfgFile def __str__(self): @@ -54,14 +61,24 @@ class OptionsParser(ConfigParser.ConfigParser): def __getattr__(self, attr): if attr.startswith('__') and attr in self.__dict__.keys(): return self.__dict__[attr] + elif self.tab.has_key(attr): + return self.tab[attr] else: - for key in self.__dict__.keys(): - if key == attr: - return self.__dict__[attr] +# for key in self.__dict__.keys(): +# if key == attr: +# return self.__dict__[attr] return None # END __getattr__ def writeCfgFile(self): + #Remove all sections + for s in self.sections(): + self.remove_section(s) + #recreate sections + for s in self.tab.keys(): + self.add_section(s) + for o in self.tab[s].keys(): + self.set(s, o, self.tab[s][o]) try: self.write(open(self.__fname, 'w')) except: diff --git a/common/plugin.py b/common/plugin.py index f4b4ad212..26e8bd345 100644 --- a/common/plugin.py +++ b/common/plugin.py @@ -4,7 +4,6 @@ ## Gajim Team: ## - Yann Le Boulanger <asterix@crans.org> ## - Vincent Hanquez <tab@tuxfamily.org> -## - David Ferlier <david@yazzy.org> ## ## Copyright (C) 2003 Gajim Team ## diff --git a/common/thread.py b/common/thread.py index 3e747db68..fa97b7a86 100644 --- a/common/thread.py +++ b/common/thread.py @@ -4,7 +4,6 @@ ## Gajim Team: ## - Yann Le Boulanger <asterix@crans.org> ## - Vincent Hanquez <tab@tuxfamily.org> -## - David Ferlier <david@yazzy.org> ## ## Copyright (C) 2003 Gajim Team ## |