persistent_pineapple¶
Persistent Pineapple provides a simple interface to save settings for applications or other modules. The settings file is in the JSON format for simplicty. A slightly modified JSON format is used to allow for comments and other creature features. Please read the _json.py file for more details.
- Example settings file::
- Example code:
>>> settings = PersistentPineapple('/etc/myapp.json') >>> print settings.program_name myapp >>> if settings.debug: ... print "we're in debug mode" we're in debug mode >>> settings.debug = False
-
class
persistent_pineapple.PersistentPineapple(path, woc=True, lofc=True)¶ An interface to the project settings.
-
get(key)¶ Return item defined by key from settings file. If lofc was set, the contents of the settings file will be reloaded if the file has been modified since last read.
-
reload()¶ Reload the settings file
-
save(path=None)¶ Save the settings back to the file
-
set(key, value)¶ Set/overwrite the currently read item. If woc was set, the settings file will be overwritten with the new settings.
-