8000 Merge pull request #2719 from michs/xdg_home-config · matplotlib/matplotlib@0efcb84 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0efcb84

Browse files
committed
Merge pull request #2719 from michs/xdg_home-config
Package initialization made possible when executed in environments with...
2 parents ecdcc74 + 98439df commit 0efcb84

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

lib/matplotlib/__init__.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -531,11 +531,12 @@ def _get_xdg_config_dir():
531531
base directory spec
532532
<http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_.
533533
"""
534-
home = get_home()
535-
if home is None:
536-
return None
537-
else:
538-
return os.environ.get('XDG_CONFIG_HOME', os.path.join(home, '.config'))
534+
path = os.environ.get('XDG_CONFIG_HOME')
535+
if path is None:
536+
path = get_home()
537+
if path is not None:
538+
path = os.path.join(path, '.config')
539+
return path
539540

540541

541542
def _get_xdg_cache_dir():
@@ -544,11 +545,12 @@ def _get_xdg_cache_dir():
544545
base directory spec
545546
<http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_.
546547
"""
547-
home = get_home()
548-
if home is None:
549-
return None
550-
else:
551-
return os.environ.get('XDG_CACHE_HOME', os.path.join(home, '.cache'))
548+
path = os.environ.get('XDG_CACHE_HOME')
549+
if path is None:
550+
path = get_home()
551+
if path is not None:
552+
path = os.path.join(path, '.cache')
553+
return path
552554

553555

554556
def _get_config_or_cache_dir(xdg_base):
@@ -568,9 +570,8 @@ def _get_config_or_cache_dir(xdg_base):
568570
h = get_home()
569571
if h is not None:
570572
p = os.path.join(h, '.matplotlib')
571-
if (sys.platform.startswith('linux') and
572-
xdg_base is not None):
573-
p = os.path.join(xdg_base, 'matplotlib')
573+
if (sys.platform.startswith('linux') and xdg_base):
574+
p = os.path.join(xdg_base, 'matplotlib')
574575

575576
if p is not None:
576577
if os.path.exists(p):

0 commit comments

Comments
 (0)
0