Skip to content

Commit 9d6259f

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 c280700 commit 9d6259f

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
@@ -115,6 +115,7 @@
115115
import locale
116116
import os
117117
import re
118+
import stat
118119
import sys
119120
import tempfile
120121
import warnings
@@ -734,8 +735,10 @@ def gen_candidates():
734735
yield os.path.join(get_data_path(), 'matplotlibrc')
735736

736737
for fname in gen_candidates():
737-
if os.path.isfile(fname):
738-
break
738+
if os.path.exists(fname):
739+
st_mode = os.stat(fname).st_mode
740+
if stat.S_ISREG(st_mode) or stat.S_ISFIFO(st_mode):
741+
break
739742
# Return first candidate that is a file, or last candidate if none is
740743
# valid (in that case, a warning is raised at startup by `rc_params`).
741744
return fname

0 commit comments

Comments
 (0)