~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/plugins/launchpad/lp_api.py

  • Committer: Jonathan Lange
  • Date: 2009-12-16 06:50:15 UTC
  • mto: This revision was merged to the branch mainline in revision 4907.
  • Revision ID: jml@canonical.com-20091216065015-45pokitp3mamgfdz
Baby steps: Move the cache directory stuff into a function.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
from lazr.uri import URI
41
41
 
42
42
 
43
 
# XXX: Not the right value for Windows
44
 
# Look in win32 utils -- maybe wrap it up
45
 
CACHE_DIRECTORY = os.path.expanduser('~/.launchpadlib/cache')
 
43
def get_cache_directory():
 
44
    """Return the directory to cache launchpadlib objects in."""
 
45
    # XXX: Not the right value for Windows. Use the same logic as config_dir
 
46
    # to get a suitable base directory, maybe extract stuff out of that.
 
47
 
 
48
    # XXX: Don't use launchpadlib/cache, use a directory called launchpadlib
 
49
    # underneath the xdg cache. (~/.cache on UNIX)
 
50
    return os.path.expanduser('~/.launchpadlib/cache')
46
51
 
47
52
 
48
53
LAUNCHPAD_API_URLS = {
80
85
    """
81
86
    web_root_uri = URI(_get_api_url(service))
82
87
    credential_name = 'creds-%s-bzr' % (web_root_uri.host)
83
 
    return os.path.join(CACHE_DIRECTORY, credential_name)
 
88
    return os.path.join(get_cache_directory(), credential_name)
84
89
 
85
90
 
86
91
def _login_from_cache(consumer_name, service_root, cache_dir,