@@ -545,6 +545,7 @@ def _get_configdir():
545545 configdir = os .environ .get ('MPLCONFIGDIR' )
546546 if configdir is not None :
547547 if not os .path .exists (configdir ):
548+ from matplotlib .cbook import mkdirs
548549 mkdirs (configdir )
549550 if not _is_writable_dir (configdir ):
550551 return _create_tmp_config_dir ()
@@ -626,9 +627,9 @@ def get_example_data(fname):
626627
627628def get_py2exe_datafiles ():
628629 datapath = get_data_path ()
629- head , tail = os .path .split (datapath )
630+ _ , tail = os .path .split (datapath )
630631 d = {}
631- for root , dirs , files in os .walk (datapath ):
632+ for root , _ , files in os .walk (datapath ):
632633 # Need to explicitly remove cocoa_agg files or py2exe complains
633634 # NOTE I dont know why, but do as previous version
634635 if 'Matplotlib.nib' in files :
@@ -642,7 +643,7 @@ def get_py2exe_datafiles():
642643
643644def matplotlib_fname ():
644645 """
645- Return the path to the rc file
646+ Return the path to the rc file used by matplotlib.
646647
647648 Search order:
648649
@@ -651,9 +652,7 @@ def matplotlib_fname():
651652 * HOME/.matplotlib/matplotlibrc
652653 * MATPLOTLIBDATA/matplotlibrc
653654
654-
655655 """
656-
657656 oldname = os .path .join (os .getcwd (), '.matplotlibrc' )
658657 if os .path .exists (oldname ):
659658 try :
@@ -815,13 +814,14 @@ def find_all(self, pattern):
815814
816815
817816def 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+ """
820820 fname = matplotlib_fname ()
821821 if not os .path .exists (fname ):
822822 # this should never happen, default in mpl-data should always be found
823823 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 \
825825 defaultParams .iteritems () ])
826826 warnings .warn (message )
827827 return ret
@@ -830,29 +830,31 @@ def rc_params(fail_on_error=False):
830830
831831
832832def 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+ """
835836 cnt = 0
836837 rc_temp = {}
837838 with open (fname ) as fd :
838839 for line in fd :
839840 cnt += 1
840- strippedline = line .split ('#' ,1 )[0 ].strip ()
841+ strippedline = line .split ('#' , 1 )[0 ].strip ()
841842 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"' % \
845846 (cnt , line , fname ))
846847 continue
847848 key , val = tup
848849 key = key .strip ()
849850 val = val .strip ()
850851 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 ))
852854 rc_temp [key ] = (val , line , cnt )
853855
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 ()])
856858
857859 for key in ('verbose.level' , 'verbose.fileo' ):
858860 if key in rc_temp :
@@ -1028,20 +1030,20 @@ class rc_context(object):
10281030
10291031 This allows one to do::
10301032
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)
10361038
10371039 The 'a' vs 'x' and 'c' vs 'x' plots would have settings from
10381040 'screen.rc', while the 'b' vs 'x' plot would have settings from
10391041 'print.rc'.
10401042
10411043 A dictionary can also be passed to the context manager::
10421044
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)
10451047
10461048 The 'rc' dictionary takes precedence over the settings loaded from
10471049 'fname'. Passing a dictionary only is also valid.
@@ -1128,7 +1130,7 @@ def use(arg, warn=True, force=False):
11281130 reload (sys .modules ['matplotlib.backends' ])
11291131
11301132def get_backend ():
1131- "Returns the current backend."
1133+ """Return the name of the current backend."" "
11321134 return rcParams ['backend' ]
11331135
11341136def interactive (b ):
0 commit comments