Index: BaseDirectory.py =================================================================== RCS file: /cvs/pyxdg/pyxdg/xdg/BaseDirectory.py,v retrieving revision 1.8 diff -u -8 -p -r1.8 BaseDirectory.py --- BaseDirectory.py 2 Mar 2008 13:58:08 -0000 1.8 +++ BaseDirectory.py 6 Feb 2010 19:29:50 -0000 @@ -42,16 +42,28 @@ xdg_config_dirs = [xdg_config_home] + \ os.environ.get('XDG_CONFIG_DIRS', '/etc/xdg').split(':') xdg_cache_home = os.environ.get('XDG_CACHE_HOME', os.path.join(_home, '.cache')) xdg_data_dirs = filter(lambda x: x, xdg_data_dirs) xdg_config_dirs = filter(lambda x: x, xdg_config_dirs) +def save_cache_path(*resource): + """Ensure $XDG_CACHE_HOME// 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_cache_home variable + for loading.""" + resource = os.path.join(*resource) + assert not resource.startswith('/') + path = os.path.join(xdg_cache_home, resource) + if not os.path.isdir(path): + os.makedirs(path) + return path + def save_config_path(*resource): """Ensure $XDG_CONFIG_HOME// 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.""" resource = os.path.join(*resource) assert not resource.startswith('/') path = os.path.join(xdg_config_home, resource)