1 """This module implements the Choices system for user preferences.
2 The environment variable CHOICESPATH gives a list of directories to search
3 for choices. Changed choices are saved back to the first directory in the
7 from os
.path
import exists
10 path
= os
.environ
['CHOICESPATH']
11 paths
= path
.split(':')
13 paths
= [ os
.environ
['HOME'] + '/Choices',
14 '/usr/local/share/Choices',
15 '/usr/share/Choices' ]
18 """When you want to load user choices, use this function. 'dir' is
19 the subdirectory within Choices where the choices are saved (usually
20 this will be the name of your program). 'leaf' is the file within it.
21 If serveral files are present, the most important one is returned. If
22 no files are there, returns None.
23 Eg ('Edit', 'Options') - > '/usr/local/share/Choices/Edit/Options'"""
27 full
= path
+ '/' + dir + '/' + leaf
33 def save(dir, leaf
, create
= 1):
34 """Returns a path to save to, or None if saving is disabled.
35 If 'create' is FALSE then no directories are created. 'dir' and
36 'leaf' are as for load()."""
42 if create
and not os
.path
.exists(p
):
45 if create
and not os
.path
.exists(p
):