Skip to content

Commit dff2db6

Browse files
committed
Allow setting MATPLOTLIBRC by process substitution.
This makes (e.g.) ``` $ MATPLOTLIBRC=<(echo 'savefig.transparent: true') python foo.py ``` use `savefig.transparent: true` as contents of matplotlibrc for the given process (on POSIX). This generalizes the MPLBACKEND mechanism to all rcParams (although the lack of "cascading" rc-files means that the "normal" rc-file is completely hidden).
1 parent 6336f2d commit dff2db6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/matplotlib/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
import os
119119
import re
120120
import shutil
121+
import stat
121122
import sys
122123
import tempfile
123124
import warnings
@@ -833,8 +834,10 @@ def gen_candidates():
833834
yield os.path.join(get_data_path(), 'matplotlibrc')
834835

835836
for fname in gen_candidates():
836-
if os.path.isfile(fname):
837-
break
837+
if os.path.exists(fname):
838+
st_mode = os.stat(fname).st_mode
839+
if stat.S_ISREG(st_mode) or stat.S_ISFIFO(st_mode):
840+
break
838841
# Return first candidate that is a file, or last candidate if none is
839842
# valid (in that case, a warning is raised at startup by `rc_params`).
840843
return fname

0 commit comments

Comments
 (0)