diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 1592e2db2274..aff198209cc7 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -531,11 +531,12 @@ def _get_xdg_config_dir(): base directory spec `_. """ - home = get_home() - if home is None: - return None - else: - return os.environ.get('XDG_CONFIG_HOME', os.path.join(home, '.config')) + path = os.environ.get('XDG_CONFIG_HOME') + if path is None: + path = get_home() + if path is not None: + path = os.path.join(path, '.config') + return path def _get_xdg_cache_dir(): @@ -544,11 +545,12 @@ def _get_xdg_cache_dir(): base directory spec `_. """ - home = get_home() - if home is None: - return None - else: - return os.environ.get('XDG_CACHE_HOME', os.path.join(home, '.cache')) + path = os.environ.get('XDG_CACHE_HOME') + if path is None: + path = get_home() + if path is not None: + path = os.path.join(path, '.cache') + return path def _get_config_or_cache_dir(xdg_base): @@ -568,9 +570,8 @@ def _get_config_or_cache_dir(xdg_base): h = get_home() if h is not None: 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 xdg_base): + p = os.path.join(xdg_base, 'matplotlib') if p is not None: if os.path.exists(p):