Skip to content

Commit

Permalink
Move checkdep_ps_distiller to the rc validators.
Browse files Browse the repository at this point in the history
  • Loading branch information
anntzer committed Oct 31, 2017
1 parent b9a67b6 commit 253099b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 2 additions & 4 deletions lib/matplotlib/__init__.py
Expand Up @@ -440,6 +440,7 @@ def checkdep_inkscape():
checkdep_inkscape.version = None


@cbook.deprecated("2.2")
def checkdep_ps_distiller(s):
if not s:
return False
Expand All @@ -449,7 +450,7 @@ def checkdep_ps_distiller(s):
return False
if s == "xpdf" and not get_executable_info("pdftops"):
warnings.warn(
"setting matplotlibrc ps.usedistiller to 'xpdf' requires xpdf.")
"Setting matplotlibrc ps.usedistiller to 'xpdf' requires xpdf.")
return False
return s

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

rcParams['ps.usedistiller'] = checkdep_ps_distiller(
rcParams['ps.usedistiller'])

rcParams['text.usetex'] = checkdep_usetex(rcParams['text.usetex'])

if rcParams['axes.formatter.use_locale']:
Expand Down
8 changes: 7 additions & 1 deletion lib/matplotlib/rcsetup.py
Expand Up @@ -25,6 +25,7 @@
import warnings
import re

import matplotlib as mpl
from matplotlib.cbook import mplDeprecation, deprecated, ls_mapper
from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
from matplotlib.colors import is_color_like
Expand Down Expand Up @@ -505,7 +506,12 @@ def validate_ps_distiller(s):
elif s in ('false', False):
return False
elif s in ('ghostscript', 'xpdf'):
return s
if not mpl.get_executable_info("gs"):
warnings.warn("Setting ps.usedistiller requires ghostscript.")
return False
if s == "xpdf" and not mpl.get_executable_info("pdftops"):
warnings.warn("Setting ps.usedistiller to 'xpdf' requires xpdf.")
return False
else:
raise ValueError('matplotlibrc ps.usedistiller must either be none, '
'ghostscript or xpdf')
Expand Down

0 comments on commit 253099b

Please sign in to comment.