Bug 26458

Summary: Create function xdg.BaseDirectory.save_cache_path()
Product: PyXDG Reporter: Sense Hofstede <sense>
Component: PyXDGAssignee: Thomas Kluyver <thomas>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: Add a xdg.BaseDirectory.save_cache_path() function

Description Sense Hofstede 2010-02-06 11:25:44 UTC
Currently there are already two functions for creating the $XDG_CONFIG_HOME and $XDG_DATA_HOME directories: xdg.BaseDirectory.save_config_path(*resource) and xdg.BaseDirectory.save_data_path(*resource).
However, despite that fact that people often purge their cache and the fact that the cache should be easy to use as well there is no xdg.BaseDirectory.save_cache_path() function.

I would suggest to add one to make the life of the developers easier.

The function would like this:

def save_cache_path(*resource):
    """Ensure $XDG_CACHE_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_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
Comment 1 Sense Hofstede 2010-02-06 11:30:44 UTC
Created attachment 33131 [details] [review]
Add a xdg.BaseDirectory.save_cache_path() function
Comment 2 Thomas Kluyver 2012-07-23 21:00:07 UTC
Thanks, I've added that with a test.

http://cgit.freedesktop.org/xdg/pyxdg/commit/?id=225e9885c85215beb162994e886ee6d528a91998

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.