From 46d49fd66c6e2ca61153cebab3f3bf7366dd0879 Mon Sep 17 00:00:00 2001 From: Danilo Bargen Date: Tue, 15 Jan 2013 00:17:24 +0100 Subject: [PATCH] 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. --- jedi/settings.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/jedi/settings.py b/jedi/settings.py index 3515f277..1b9125b6 100644 --- a/jedi/settings.py +++ b/jedi/settings.py @@ -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\\``. """ # ----------------