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

Skip to content

Commit 45a9968

Browse files
committed
fix small problems left by rc refactoring
svn path=/trunk/matplotlib/; revision=3445
1 parent a1649d9 commit 45a9968

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

lib/matplotlib/__init__.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@
175175

176176
import sys, os, tempfile
177177

178-
from rcdefaults import defaultParams
178+
from rcdefaults import defaultParams, validate_backend, validate_toolbar
179179

180180
major, minor1, minor2, s, tmp = sys.version_info
181181
_python23 = major>=2 and minor1>=3
@@ -469,7 +469,7 @@ def _get_home():
469469

470470
def _get_configdir():
471471
"""
472-
Return the string representing the configuration dir.
472+
Return the string representing the configuration dir.
473473
474474
default is HOME/.matplotlib. you can override this with the
475475
MPLCONFIGDIR environment variable
@@ -480,10 +480,10 @@ def _get_configdir():
480480
if not _is_writable_dir(configdir):
481481
raise RuntimeError('Could not write to MPLCONFIGDIR="%s"'%configdir)
482482
return configdir
483-
483+
484484
h = get_home()
485485
p = os.path.join(get_home(), '.matplotlib')
486-
486+
487487
if os.path.exists(p):
488488
if not _is_writable_dir(p):
489489
raise RuntimeError("'%s' is not a writable dir; you must set %s/.matplotlib to be a writable dir. You can also set environment variable MPLCONFIGDIR to any writable directory where you want matplotlib data stored "%h)
@@ -781,12 +781,13 @@ def rcdefaults():
781781
# flag)
782782

783783
for s in sys.argv[1:]:
784-
if s.startswith('-d'): # look for a -d flag
785-
name = validate_backend(s[2:].strip(), fail_on_err = False)
786-
# we don't want to assume all -d flags are backends, eg -debug
787-
if name:
784+
if s.startswith('-d') and len(s) > 2: # look for a -d flag
785+
try:
786+
name = validate_backend(s[2:].strip())
788787
rcParams['backend'] = name
789-
break
788+
except (KeyError, ValueError):
789+
pass
790+
# we don't want to assume all -d flags are backends, eg -debug
790791

791792
def use(arg):
792793
"""

0 commit comments

Comments
 (0)