Skip to content

_get_xdg_config_dir(), _get_xdg_cache_dir() - Restored for conformity to the standard. #2692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,11 +535,10 @@ def _get_xdg_config_dir():
base directory spec
<http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_.
"""
home = get_home()
if home is None:
return None
else:
return os.environ.get('XDG_CONFIG_HOME', os.path.join(home, '.config'))
path = get_home()
if path:
path = os.path.join(path, '.config')
return os.environ.get('XDG_CONFIG_HOME', path)


def _get_xdg_cache_dir():
Expand All @@ -548,11 +547,10 @@ def _get_xdg_cache_dir():
base directory spec
<http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_.
"""
home = get_home()
if home is None:
return None
else:
return os.environ.get('XDG_CACHE_HOME', os.path.join(home, '.cache'))
path = get_home()
if path:
path = os.path.join(path, '.cache')
return os.environ.get('XDG_CACHE_HOME', path)


def _get_config_or_cache_dir(xdg_base):
Expand All @@ -570,13 +568,16 @@ def _get_config_or_cache_dir(xdg_base):

p = None
h = get_home()
if h is not None:
if h:
p = os.path.join(h, '.matplotlib')
if (sys.platform.startswith('linux') and
xdg_base is not None):
p = os.path.join(xdg_base, 'matplotlib')
if sys.platform.startswith('linux') and not os.path.exists(p):
# no old config exists
if xdg_base:
p = os.path.join(xdg_base, 'matplotlib')
else:
p = None

if p is not None:
if p:
if os.path.exists(p):
if _is_writable_dir(p):
return p
Expand Down