Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 253099b

Browse files
committed
Move checkdep_ps_distiller to the rc validators.
1 parent b9a67b6 commit 253099b

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

lib/matplotlib/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ def checkdep_inkscape():
440440
checkdep_inkscape.version = None
441441

442442

443+
@cbook.deprecated("2.2")
443444
def checkdep_ps_distiller(s):
444445
if not s:
445446
return False
@@ -449,7 +450,7 @@ def checkdep_ps_distiller(s):
449450
return False
450451
if s == "xpdf" and not get_executable_info("pdftops"):
451452
warnings.warn(
452-
"setting matplotlibrc ps.usedistiller to 'xpdf' requires xpdf.")
453+
"Setting matplotlibrc ps.usedistiller to 'xpdf' requires xpdf.")
453454
return False
454455
return s
455456

@@ -1066,9 +1067,6 @@ def rc_params_from_file(fname, fail_on_error=False, use_default_template=True):
10661067
six.iteritems(defaultParams)
10671068
if key not in _all_deprecated])
10681069

1069-
rcParams['ps.usedistiller'] = checkdep_ps_distiller(
1070-
rcParams['ps.usedistiller'])
1071-
10721070
rcParams['text.usetex'] = checkdep_usetex(rcParams['text.usetex'])
10731071

10741072
if rcParams['axes.formatter.use_locale']:

lib/matplotlib/rcsetup.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import warnings
2626
import re
2727

28+
import matplotlib as mpl
2829
from matplotlib.cbook import mplDeprecation, deprecated, ls_mapper
2930
from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
3031
from matplotlib.colors import is_color_like
@@ -505,7 +506,12 @@ def validate_ps_distiller(s):
505506
elif s in ('false', False):
506507
return False
507508
elif s in ('ghostscript', 'xpdf'):
508-
return s
509+
if not mpl.get_executable_info("gs"):
510+
warnings.warn("Setting ps.usedistiller requires ghostscript.")
511+
return False
512+
if s == "xpdf" and not mpl.get_executable_info("pdftops"):
513+
warnings.warn("Setting ps.usedistiller to 'xpdf' requires xpdf.")
514+
return False
509515
else:
510516
raise ValueError('matplotlibrc ps.usedistiller must either be none, '
511517
'ghostscript or xpdf')

0 commit comments

Comments
 (0)