This class handles preferences and stores them into given configfile
To use it :
- instanciate a Preferences object :
myPP=Preferences()
- to get a preference :
mypref=myPP["ma_preference"]
- to set a preference :
myPP["ma_preference"]=xxx
The preferences are automatically loaded on the first instanciation of this
class and are saved when a value is added or changed automatically, too.
Methods
|
|
__getitem__
__init__
__loadConfig
__saveConfig
__setitem__
|
|
__getitem__
|
__getitem__ ( self, name )
Return the preferences for the given item
@param String name : Name of the item for which we return a value
@return String : value of the pref, or None if inexistant
@since 1.1.2.7
@author C.Dutoit <dutoitc@hotmail.com>
|
|
__init__
|
__init__ ( self, filename )
Constructor
@author C.Dutoit <dutoitc@hotmail.com>
|
|
__loadConfig
|
__loadConfig ( self )
Load datas from config file
@since 1.1.2.5
@author C.Dutoit <dutoitc@hotmail.com>
|
|
__saveConfig
|
__saveConfig ( self )
Save datas to config file
@since 1.1.2.5
@author C.Dutoit <dutoitc@hotmail.com>
|
|
__setitem__
|
__setitem__ (
self,
name,
value,
)
Return the preferences for the given item
@param String name : Name of the item WITHOUT SPACES
@param String Value : Value for the given name
@raises TypeError : if the name contains spaces
@since 1.1.2.7
@author C.Dutoit <dutoitc@hotmail.com>
Exceptions
|
|
TypeError, "Name cannot contain a space"
|
|
|