@@ -387,7 +387,19 @@ def ge(self, level):
387
387
388
388
389
389
def _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.
391
403
return functools .partial (_logged_cached , fmt )
392
404
393
405
called = False
@@ -569,7 +581,7 @@ def _get_xdg_config_dir():
569
581
<http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_.
570
582
"""
571
583
return (os .environ .get ('XDG_CONFIG_HOME' )
572
- or (Path (get_home (), ".config" )
584
+ or (str ( Path (get_home (), ".config" ) )
573
585
if get_home ()
574
586
else None ))
575
587
@@ -581,21 +593,21 @@ def _get_xdg_cache_dir():
581
593
<http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_.
582
594
"""
583
595
return (os .environ .get ('XDG_CACHE_HOME' )
584
- or (Path (get_home (), ".cache" )
596
+ or (str ( Path (get_home (), ".cache" ) )
585
597
if get_home ()
586
598
else None ))
587
599
588
600
589
601
def _get_config_or_cache_dir (xdg_base ):
590
602
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
599
611
600
612
if configdir :
601
613
try :
0 commit comments