@@ -387,7 +387,19 @@ def ge(self, level):
387387
388388
389389def _logged_cached (fmt , func = None ):
390- if func is None :
390+ """
391+ Decorator that logs a function's return value, and memoizes that value.
392+
393+ After ::
394+
395+ @_logged_cached(fmt)
396+ def func(): ...
397+
398+ the first call to *func* will log its return value at the DEBUG level using
399+ %-format string *fmt*, and memoize it; later calls to *func* will directly
400+ return that value.
401+ """
402+ if func is None : # Return the actual decorator.
391403 return functools .partial (_logged_cached , fmt )
392404
393405 called = False
@@ -569,7 +581,7 @@ def _get_xdg_config_dir():
569581 <http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_.
570582 """
571583 return (os .environ .get ('XDG_CONFIG_HOME' )
572- or (Path (get_home (), ".config" )
584+ or (str ( Path (get_home (), ".config" ) )
573585 if get_home ()
574586 else None ))
575587
@@ -581,21 +593,21 @@ def _get_xdg_cache_dir():
581593 <http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_.
582594 """
583595 return (os .environ .get ('XDG_CACHE_HOME' )
584- or (Path (get_home (), ".cache" )
596+ or (str ( Path (get_home (), ".cache" ) )
585597 if get_home ()
586598 else None ))
587599
588600
589601def _get_config_or_cache_dir (xdg_base ):
590602 configdir = os .environ .get ('MPLCONFIGDIR' )
591- configdir = (
592- Path (configdir ).resolve ()
593- if configdir
594- else Path (xdg_base , "matplotlib" )
595- if sys . platform . startswith (( 'linux' , 'freebsd' )) and xdg_base
596- else Path (get_home (), ".matplotlib" )
597- if get_home ()
598- else None )
603+ if configdir :
604+ configdir = Path (configdir ).resolve ()
605+ elif sys . platform . startswith (( 'linux' , 'freebsd' )) and xdg_base :
606+ configdir = Path (xdg_base , "matplotlib" )
607+ elif get_home ():
608+ configdir = Path (get_home (), ".matplotlib" )
609+ else :
610+ configdir = None
599611
600612 if configdir :
601613 try :
0 commit comments