Cross platform cachedir, again.

Another attempt at getting a cross-platform and (on Linux) XDG compliant cache dir.

Squashed commit of the following:

- Correct usage of os.getenv (thx @tkf)
- Use `~/.cache/jedi` as default fallback, not `~/.jedi`
- Updated cache location for OS X
- Added expanduser to cachedir
- Cross platform cachedir, again.
This commit is contained in:
Danilo Bargen
2013-01-15 00:17:24 +01:00
parent f3f7eacae3
commit 46d49fd66c

View File

@@ -81,6 +81,8 @@ Various
"""
import os
import platform
# ----------------
# completion output settings
@@ -119,10 +121,18 @@ use_filesystem_cache = True
Use filesystem cache to save once parsed files with pickle.
"""
import os
cache_directory = os.getenv('HOME') + os.path.sep + '.jedi'
if platform.system().lower() == 'windows':
_cache_directory = os.path.join(os.getenv('APPDATA') or '~', 'Jedi', 'Jedi')
elif platform.system().lower() == 'darwin':
_cache_directory = os.path.join('~', 'Library', 'Caches', 'Jedi')
else:
_cache_directory = os.path.join(os.getenv('XDG_CACHE_HOME') or '~/.cache', 'jedi')
cache_directory = os.path.expanduser(_cache_directory)
"""
The path where all the caches can be found.
On Linux, this defaults to ``~/.cache/jedi/``, on OS X to ``~/.jedi/`` and on
Windows to ``%APPDATA%\\Jedi\\Jedi\\``.
"""
# ----------------