@@ -532,7 +532,11 @@ def _get_xdg_config_dir():
532
532
base directory spec
533
533
<http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_.
534
534
"""
535
- return os .environ .get ('XDG_CONFIG_HOME' , os .path .join (get_home (), '.config' ))
535
+ home = get_home ()
536
+ if home is None :
537
+ return None
538
+ else :
539
+ return os .environ .get ('XDG_CONFIG_HOME' , os .path .join (home , '.config' ))
536
540
537
541
538
542
def _get_xdg_cache_dir ():
@@ -541,7 +545,11 @@ def _get_xdg_cache_dir():
541
545
base directory spec
542
546
<http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_.
543
547
"""
544
- return os .environ .get ('XDG_CACHE_HOME' , os .path .join (get_home (), '.cache' ))
548
+ home = get_home ()
549
+ if home is None :
550
+ return None
551
+ else :
552
+ return os .environ .get ('XDG_CACHE_HOME' , os .path .join (home , '.cache' ))
545
553
546
554
547
555
def _get_config_or_cache_dir (xdg_base ):
@@ -557,22 +565,28 @@ def _get_config_or_cache_dir(xdg_base):
557
565
return _create_tmp_config_dir ()
558
566
return configdir
559
567
568
+ p = None
560
569
h = get_home ()
561
- p = os .path .join (h , '.matplotlib' )
562
- if (sys .platform .startswith ('linux' ) and
563
- not os .path .exists (p )):
564
- p = os .path .join (xdg_base , 'matplotlib' )
565
-
566
- if os .path .exists (p ):
567
- if not _is_writable_dir (p ):
568
- return _create_tmp_config_dir ()
569
- else :
570
- try :
571
- mkdirs (p )
572
- except OSError :
573
- return _create_tmp_config_dir ()
570
+ if h is not None :
571
+ p = os .path .join (h , '.matplotlib' )
572
+ if (sys .platform .startswith ('linux' ) and
573
+ not os .path .exists (p ) and
574
+ xdg_base is not None ):
575
+ p = os .path .join (xdg_base , 'matplotlib' )
576
+
577
+ if p is not None :
578
+ if os .path .exists (p ):
579
+ if _is_writable_dir (p ):
580
+ return p
581
+ else :
582
+ try :
583
+ mkdirs (p )
584
+ except OSError :
585
+ pass
586
+ else :
587
+ return p
574
588
575
- return p
589
+ return _create_tmp_config_dir ()
576
590
577
591
578
592
def _get_configdir ():
@@ -728,9 +742,11 @@ def matplotlib_fname():
728
742
if configdir is not None :
729
743
fname = os .path .join (configdir , 'matplotlibrc' )
730
744
if os .path .exists (fname ):
745
+ home = get_home ()
731
746
if (sys .platform .startswith ('linux' ) and
747
+ home is not None and
732
748
fname == os .path .join (
733
- get_home () , '.matplotlib' , 'matplotlibrc' )):
749
+ home , '.matplotlib' , 'matplotlibrc' )):
734
750
warnings .warn (
735
751
"Found matplotlib configuration in ~/.matplotlib/. "
736
752
"To conform with the XDG base directory standard, "
0 commit comments