cleaned up; used happdoc
This commit is contained in:
parent
c473798003
commit
9cab568312
18 changed files with 2190 additions and 52 deletions
|
@ -1,22 +1,20 @@
|
|||
#!/usr/bin/env python
|
||||
"""
|
||||
This Class is derived mainly from 'gimini' project.
|
||||
__version__ = "$Revision: 1.1 $"
|
||||
__author__ = "C.Dutoit <dutoitc@hotmail.com>"
|
||||
__date__ = "2003-2-14"
|
||||
'''
|
||||
read and write configuration
|
||||
|
||||
Thanx to Dutoit!
|
||||
"""
|
||||
This Class is derived mainly from 'gimini' project.
|
||||
Thanx to Dutoit! <dutoitc(at)hotmail.com>
|
||||
'''
|
||||
|
||||
from ConfigParser import *
|
||||
import sys, os
|
||||
|
||||
### Set the Preferences filename
|
||||
PREFS_FILENAME="cbx.conf"
|
||||
|
||||
|
||||
class Preferences:
|
||||
"""
|
||||
This class handle preferences and store them into 'PREFS_FILENAME'
|
||||
This class handles preferences and stores them into given configfile
|
||||
|
||||
To use it :
|
||||
- instanciate a Preferences object :
|
||||
|
@ -29,12 +27,13 @@ class Preferences:
|
|||
The preferences are automatically loaded on the first instanciation of this
|
||||
class and are saved when a value is added or changed automatically, too.
|
||||
"""
|
||||
def __init__(self):
|
||||
def __init__(self, filename):
|
||||
"""
|
||||
Constructor
|
||||
|
||||
@author C.Dutoit <dutoitc@hotmail.com>
|
||||
"""
|
||||
self.prefsfilename = filename
|
||||
self._config = None
|
||||
self.__loadConfig()
|
||||
|
||||
|
@ -91,7 +90,7 @@ class Preferences:
|
|||
@since 1.1.2.5
|
||||
@author C.Dutoit <dutoitc@hotmail.com>
|
||||
"""
|
||||
f=open(PREFS_FILENAME, "w")
|
||||
f=open(self.prefsfilename, "w")
|
||||
self._config.write(f)
|
||||
f.close()
|
||||
|
||||
|
@ -106,21 +105,21 @@ class Preferences:
|
|||
"""
|
||||
# Make sure that the configuration file exist
|
||||
try:
|
||||
f = open(PREFS_FILENAME, "r")
|
||||
f = open(self.prefsfilename, "r")
|
||||
f.close()
|
||||
except:
|
||||
try:
|
||||
f = open(PREFS_FILENAME, "w")
|
||||
f = open(self.prefsfilename, "w")
|
||||
f.write("")
|
||||
f.close()
|
||||
except:
|
||||
print "Can't make %s for saving preferences !" % PREFS_FILENAME
|
||||
print "Can't make %s for saving preferences !" % self.prefsfilename
|
||||
return
|
||||
|
||||
|
||||
# Read datas
|
||||
self._config=ConfigParser()
|
||||
self._config.read(PREFS_FILENAME)
|
||||
self._config.read(self.prefsfilename)
|
||||
|
||||
#>--------------------------------------------------------------------------
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue