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

Skip to content

Commit d0186fc

Browse files
committed
split dependency check from option validation of ps_distiller
svn path=/trunk/matplotlib/; revision=3428
1 parent 26df2bf commit d0186fc

File tree

1 file changed

+32
-25
lines changed

1 file changed

+32
-25
lines changed

lib/matplotlib/__init__.py

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -642,35 +642,40 @@ def validate_ps_distiller(s):
642642
elif s == 'false':
643643
return False
644644
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')
657648

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
666652

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
669670
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
671677
else:
672-
raise ValueError('matplotlibrc ps.usedistiller must either be none, '
673-
'ghostscript or xpdf')
678+
return False
674679

675680
def validate_usetex(s):
676681
if not validate_bool(s):
@@ -1068,6 +1073,8 @@ def rc_params(fail_on_error=False):
10681073

10691074
rcParamsDefault = dict(rcParams.items()) # a copy
10701075

1076+
rcParams['ps.usedistiller'] = checkdep_ps_distiller(rcParams['ps.usedistiller'])
1077+
10711078
def rc(group, **kwargs):
10721079
"""
10731080
Set the current rc params. Group is the grouping for the rc, eg

0 commit comments

Comments
 (0)