@@ -387,6 +387,19 @@ def ge(self, level):
387
387
388
388
389
389
def _logged_cached (fmt , func = 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
+
390
403
if func is None :
391
404
return functools .partial (_logged_cached , fmt )
392
405
@@ -569,7 +582,7 @@ def _get_xdg_config_dir():
569
582
<http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_.
570
583
"""
571
584
return (os .environ .get ('XDG_CONFIG_HOME' )
572
- or (Path (get_home (), ".config" )
585
+ or (str ( Path (get_home (), ".config" ) )
573
586
if get_home ()
574
587
else None ))
575
588
@@ -581,21 +594,21 @@ def _get_xdg_cache_dir():
581
594
<http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_.
582
595
"""
583
596
return (os .environ .get ('XDG_CACHE_HOME' )
584
- or (Path (get_home (), ".cache" )
597
+ or (str ( Path (get_home (), ".cache" ) )
585
598
if get_home ()
586
599
else None ))
587
600
588
601
589
602
def _get_config_or_cache_dir (xdg_base ):
590
603
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 )
604
+ if configdir :
605
+ configdir = Path (configdir ).resolve ()
606
+ elif sys . platform . startswith (( 'linux' , 'freebsd' )) and xdg_base :
607
+ configdir = Path (xdg_base , "matplotlib" )
608
+ elif get_home ():
609
+ configdir = Path (get_home (), ".matplotlib" )
610
+ else :
611
+ configdir = None
599
612
600
613
if configdir :
601
614
try :
0 commit comments