Bug 26458 - Create function xdg.BaseDirectory.save_cache_path()
Create function xdg.BaseDirectory.save_cache_path()
Status: RESOLVED FIXED
Product: PyXDG
Classification: Unclassified
Component: PyXDG
unspecified
Other All
: medium normal
Assigned To: Thomas Kluyver
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-02-06 11:25 UTC by Sense Hofstede
Modified: 2012-07-23 21:00 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Add a xdg.BaseDirectory.save_cache_path() function (1.49 KB, patch)
2010-02-06 11:30 UTC, Sense Hofstede
Details | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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