@@ -545,6 +545,7 @@ def _get_configdir():
545
545
configdir = os .environ .get ('MPLCONFIGDIR' )
546
546
if configdir is not None :
547
547
if not os .path .exists (configdir ):
548
+ from matplotlib .cbook import mkdirs
548
549
mkdirs (configdir )
549
550
if not _is_writable_dir (configdir ):
550
551
return _create_tmp_config_dir ()
@@ -626,9 +627,9 @@ def get_example_data(fname):
626
627
627
628
def get_py2exe_datafiles ():
628
629
datapath = get_data_path ()
629
- head , tail = os .path .split (datapath )
630
+ _ , tail = os .path .split (datapath )
630
631
d = {}
631
- for root , dirs , files in os .walk (datapath ):
632
+ for root , _ , files in os .walk (datapath ):
632
633
# Need to explicitly remove cocoa_agg files or py2exe complains
633
634
# NOTE I dont know why, but do as previous version
634
635
if 'Matplotlib.nib' in files :
@@ -642,7 +643,7 @@ def get_py2exe_datafiles():
642
643
643
644
def matplotlib_fname ():
644
645
"""
645
- Return the path to the rc file
646
+ Return the path to the rc file used by matplotlib.
646
647
647
648
Search order:
648
649
@@ -651,9 +652,7 @@ def matplotlib_fname():
651
652
* HOME/.matplotlib/matplotlibrc
652
653
* MATPLOTLIBDATA/matplotlibrc
653
654
654
-
655
655
"""
656
-
657
656
oldname = os .path .join (os .getcwd (), '.matplotlibrc' )
658
657
if os .path .exists (oldname ):
659
658
try :
@@ -815,13 +814,14 @@ def find_all(self, pattern):
815
814
816
815
817
816
def rc_params (fail_on_error = False ):
818
- 'Return the default params updated from the values in the rc file'
819
-
817
+ """Return a :class:`matplotlib.RcParams` instance from the
818
+ default matplotlib rc file.
819
+ """
820
820
fname = matplotlib_fname ()
821
821
if not os .path .exists (fname ):
822
822
# this should never happen, default in mpl-data should always be found
823
823
message = 'could not find rc file; returning defaults'
824
- ret = RcParams ([ (key , default ) for key , (default , converter ) in \
824
+ ret = RcParams ([(key , default ) for key , (default , _ ) in \
825
825
defaultParams .iteritems () ])
826
826
warnings .warn (message )
827
827
return ret
@@ -830,29 +830,31 @@ def rc_params(fail_on_error=False):
830
830
831
831
832
832
def rc_params_from_file (fname , fail_on_error = False ):
833
- """Load and return params from fname."""
834
-
833
+ """Return a :class:`matplotlib.RcParams` instance from the
834
+ contents of the given filename.
835
+ """
835
836
cnt = 0
836
837
rc_temp = {}
837
838
with open (fname ) as fd :
838
839
for line in fd :
839
840
cnt += 1
840
- strippedline = line .split ('#' ,1 )[0 ].strip ()
841
+ strippedline = line .split ('#' , 1 )[0 ].strip ()
841
842
if not strippedline : continue
842
- tup = strippedline .split (':' ,1 )
843
- if len (tup ) != 2 :
844
- warnings .warn ('Illegal line #%d\n \t %s\n \t in file "%s"' % \
843
+ tup = strippedline .split (':' , 1 )
844
+ if len (tup ) != 2 :
845
+ warnings .warn ('Illegal line #%d\n \t %s\n \t in file "%s"' % \
845
846
(cnt , line , fname ))
846
847
continue
847
848
key , val = tup
848
849
key = key .strip ()
849
850
val = val .strip ()
850
851
if key in rc_temp :
851
- warnings .warn ('Duplicate key in file "%s", line #%d' % (fname ,cnt ))
852
+ warnings .warn ('Duplicate key in file "%s", line #%d' % \
853
+ (fname , cnt ))
852
854
rc_temp [key ] = (val , line , cnt )
853
855
854
- ret = RcParams ([ (key , default ) for key , (default , converter ) in \
855
- defaultParams .iteritems () ])
856
+ ret = RcParams ([(key , default ) for key , (default , _ ) in \
857
+ defaultParams .iteritems ()])
856
858
857
859
for key in ('verbose.level' , 'verbose.fileo' ):
858
860
if key in rc_temp :
@@ -1028,20 +1030,20 @@ class rc_context(object):
1028
1030
1029
1031
This allows one to do::
1030
1032
1031
- >>> with mpl.rc_context(fname='screen.rc'):
1032
- ... plt.plot(x, a)
1033
- ... with mpl.rc_context(fname='print.rc'):
1034
- ... plt.plot(x, b)
1035
- ... plt.plot(x, c)
1033
+ with mpl.rc_context(fname='screen.rc'):
1034
+ plt.plot(x, a)
1035
+ with mpl.rc_context(fname='print.rc'):
1036
+ plt.plot(x, b)
1037
+ plt.plot(x, c)
1036
1038
1037
1039
The 'a' vs 'x' and 'c' vs 'x' plots would have settings from
1038
1040
'screen.rc', while the 'b' vs 'x' plot would have settings from
1039
1041
'print.rc'.
1040
1042
1041
1043
A dictionary can also be passed to the context manager::
1042
1044
1043
- >>> with mpl.rc_context(rc={'text.usetex': True}, fname='screen.rc'):
1044
- ... plt.plot(x, a)
1045
+ with mpl.rc_context(rc={'text.usetex': True}, fname='screen.rc'):
1046
+ plt.plot(x, a)
1045
1047
1046
1048
The 'rc' dictionary takes precedence over the settings loaded from
1047
1049
'fname'. Passing a dictionary only is also valid.
@@ -1128,7 +1130,7 @@ def use(arg, warn=True, force=False):
1128
1130
reload (sys .modules ['matplotlib.backends' ])
1129
1131
1130
1132
def get_backend ():
1131
- "Returns the current backend."
1133
+ """Return the name of the current backend."" "
1132
1134
return rcParams ['backend' ]
1133
1135
1134
1136
def interactive (b ):
0 commit comments