Python: module rox.basedir

rox.basedir | index

`The freedesktop.org Base Directory specification provides a way for
applications to locate shared data and configuration:
http://www.freedesktop.org/standards/
This module can be used to load and save from and to these directories.
Typical usage:
from rox import basedir
for dir in basedir.load_config_paths('mydomain.org', 'MyProg', 'Options'):
print "Load settings from", dir
dir = basedir.save_config_path('mydomain.org', 'MyProg')
print >>file(os.path.join(dir, 'Options'), 'w'), "foo=2"
Note: see the rox.Options module for a higher-level API for managing options.`

Functions
`` |  | load_config_paths(*resource) `Returns an iterator which gives each directory named 'resource' in the configuration search path. Information provided by earlier directories should take precedence over later ones (ie, the user's config dir comes first).` load_data_paths(*resource) `Returns an iterator which gives each directory named 'resource' in the shared data search path. Information provided by earlier directories should take precedence over later ones.` load_first_config(*resource) `Returns the first result from load_config_paths, or None if there is nothing to load.` save_config_path(*resource) `Ensure $XDG_CONFIG_HOME/<resource>/ exists, and return its path. 'resource' should normally be the name of your application. Use this when SAVING configuration settings. Use the xdg_config_dirs variable for loading.` save_data_path(*resource) `Ensure $XDG_DATA_HOME/<resource>/ exists, and return its path. 'resource' is the name of some shared resource. Use this when updating a shared (between programs) database. Use the xdg_data_dirs variable for loading.`