@@ -642,35 +642,40 @@ def validate_ps_distiller(s):
642
642
elif s == 'false' :
643
643
return False
644
644
elif s in ('ghostscript' , 'xpdf' ):
645
- flag = True
646
- gs_req = '7.07'
647
- gs_sugg = '7.07'
648
- gs_v = checkdep_ghostscript ()
649
- if compare_versions (gs_v , gs_sugg ): pass
650
- elif compare_versions (gs_v , gs_req ):
651
- verbose .report (('ghostscript-%s found. ghostscript-%s or later '
652
- 'is recommended to use the ps.usedistiller option.' ) % (gs_v , gs_sugg ))
653
- else :
654
- flag = False
655
- warnings .warn (('matplotlibrc ps.usedistiller option can not be used '
656
- 'unless ghostscript-%s or later is installed on your system' ) % gs_req )
645
+ return s
646
+ else :
647
+ raise ValueError ('matplotlibrc ps.usedistiller must either be none, ghostscript or xpdf' )
657
648
658
- if s == 'xpdf' :
659
- pdftops_req = '3.0'
660
- pdftops_v = checkdep_pdftops ()
661
- if compare_versions (pdftops_v , pdftops_req ): pass
662
- else :
663
- flag = False
664
- warnings .warn (('matplotlibrc ps.usedistiller can not be set to '
665
- 'xpdf unless xpdf-%s or later is installed on your system' ) % pdftops_req )
649
+ def checkdep_ps_distiller (s ):
650
+ if not s :
651
+ return False
666
652
667
- if flag :
668
- return s
653
+ flag = True
654
+ gs_req = '7.07'
655
+ gs_sugg = '7.07'
656
+ gs_v = checkdep_ghostscript ()
657
+ if compare_versions (gs_v , gs_sugg ): pass
658
+ elif compare_versions (gs_v , gs_req ):
659
+ verbose .report (('ghostscript-%s found. ghostscript-%s or later '
660
+ 'is recommended to use the ps.usedistiller option.' ) % (gs_v , gs_sugg ))
661
+ else :
662
+ flag = False
663
+ warnings .warn (('matplotlibrc ps.usedistiller option can not be used '
664
+ 'unless ghostscript-%s or later is installed on your system' ) % gs_req )
665
+
666
+ if s == 'xpdf' :
667
+ pdftops_req = '3.0'
668
+ pdftops_v = checkdep_pdftops ()
669
+ if compare_versions (pdftops_v , pdftops_req ): pass
669
670
else :
670
- return None
671
+ flag = False
672
+ warnings .warn (('matplotlibrc ps.usedistiller can not be set to '
673
+ 'xpdf unless xpdf-%s or later is installed on your system' ) % pdftops_req )
674
+
675
+ if flag :
676
+ return s
671
677
else :
672
- raise ValueError ('matplotlibrc ps.usedistiller must either be none, '
673
- 'ghostscript or xpdf' )
678
+ return False
674
679
675
680
def validate_usetex (s ):
676
681
if not validate_bool (s ):
@@ -1068,6 +1073,8 @@ def rc_params(fail_on_error=False):
1068
1073
1069
1074
rcParamsDefault = dict (rcParams .items ()) # a copy
1070
1075
1076
+ rcParams ['ps.usedistiller' ] = checkdep_ps_distiller (rcParams ['ps.usedistiller' ])
1077
+
1071
1078
def rc (group , ** kwargs ):
1072
1079
"""
1073
1080
Set the current rc params. Group is the grouping for the rc, eg
0 commit comments