@@ -497,6 +497,7 @@ def checkdep_usetex(s):
497497 return True
498498
499499
500+ @cbook .deprecated ("3.2" , alternative = "os.path.expanduser('~')" )
500501@_logged_cached ('$HOME=%s' )
501502def get_home ():
502503 """
@@ -526,10 +527,7 @@ def _get_xdg_config_dir():
526527 base directory spec
527528 <http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_.
528529 """
529- return (os .environ .get ('XDG_CONFIG_HOME' )
530- or (str (Path (get_home (), ".config" ))
531- if get_home ()
532- else None ))
530+ return os .environ .get ('XDG_CONFIG_HOME' ) or str (Path .home () / ".config" )
533531
534532
535533def _get_xdg_cache_dir ():
@@ -538,10 +536,7 @@ def _get_xdg_cache_dir():
538536 base directory spec
539537 <http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_.
540538 """
541- return (os .environ .get ('XDG_CACHE_HOME' )
542- or (str (Path (get_home (), ".cache" ))
543- if get_home ()
544- else None ))
539+ return os .environ .get ('XDG_CACHE_HOME' ) or str (Path .home () / ".cache" )
545540
546541
547542def _get_config_or_cache_dir (xdg_base ):
@@ -550,20 +545,15 @@ def _get_config_or_cache_dir(xdg_base):
550545 configdir = Path (configdir ).resolve ()
551546 elif sys .platform .startswith (('linux' , 'freebsd' )) and xdg_base :
552547 configdir = Path (xdg_base , "matplotlib" )
553- elif get_home ():
554- configdir = Path (get_home (), ".matplotlib" )
555548 else :
556- configdir = None
557-
558- if configdir :
559- try :
560- configdir .mkdir (parents = True , exist_ok = True )
561- except OSError :
562- pass
563- else :
564- if os .access (str (configdir ), os .W_OK ) and configdir .is_dir ():
565- return str (configdir )
566-
549+ configdir = Path .home () / ".matplotlib"
550+ try :
551+ configdir .mkdir (parents = True , exist_ok = True )
552+ except OSError :
553+ pass
554+ else :
555+ if os .access (str (configdir ), os .W_OK ) and configdir .is_dir ():
556+ return str (configdir )
567557 return _create_tmp_config_or_cache_dir ()
568558
569559
0 commit comments