@@ -549,6 +549,7 @@ def _get_configdir():
549549 configdir = os .environ .get ('MPLCONFIGDIR' )
550550 if configdir is not None :
551551 if not os .path .exists (configdir ):
552+ from matplotlib .cbook import mkdirs
552553 mkdirs (configdir )
553554 if not _is_writable_dir (configdir ):
554555 return _create_tmp_config_dir ()
@@ -631,9 +632,9 @@ def get_example_data(fname):
631632
632633def get_py2exe_datafiles ():
633634 datapath = get_data_path ()
634- head , tail = os .path .split (datapath )
635+ _ , tail = os .path .split (datapath )
635636 d = {}
636- for root , dirs , files in os .walk (datapath ):
637+ for root , _ , files in os .walk (datapath ):
637638 # Need to explicitly remove cocoa_agg files or py2exe complains
638639 # NOTE I dont know why, but do as previous version
639640 if 'Matplotlib.nib' in files :
@@ -647,7 +648,7 @@ def get_py2exe_datafiles():
647648
648649def matplotlib_fname ():
649650 """
650- Return the path to the rc file
651+ Return the path to the rc file used by matplotlib.
651652
652653 Search order:
653654
@@ -656,9 +657,7 @@ def matplotlib_fname():
656657 * HOME/.matplotlib/matplotlibrc
657658 * MATPLOTLIBDATA/matplotlibrc
658659
659-
660660 """
661-
662661 oldname = os .path .join (os .getcwd (), '.matplotlibrc' )
663662 if os .path .exists (oldname ):
664663 try :
@@ -820,13 +819,14 @@ def find_all(self, pattern):
820819
821820
822821def rc_params (fail_on_error = False ):
823- 'Return the default params updated from the values in the rc file'
824-
822+ """Return a :class:`matplotlib.RcParams` instance from the
823+ default matplotlib rc file.
824+ """
825825 fname = matplotlib_fname ()
826826 if not os .path .exists (fname ):
827827 # this should never happen, default in mpl-data should always be found
828828 message = 'could not find rc file; returning defaults'
829- ret = RcParams ([ (key , default ) for key , (default , converter ) in \
829+ ret = RcParams ([(key , default ) for key , (default , _ ) in \
830830 defaultParams .iteritems () ])
831831 warnings .warn (message )
832832 return ret
@@ -835,29 +835,31 @@ def rc_params(fail_on_error=False):
835835
836836
837837def rc_params_from_file (fname , fail_on_error = False ):
838- """Load and return params from fname."""
839-
838+ """Return a :class:`matplotlib.RcParams` instance from the
839+ contents of the given filename.
840+ """
840841 cnt = 0
841842 rc_temp = {}
842843 with open (fname ) as fd :
843844 for line in fd :
844845 cnt += 1
845- strippedline = line .split ('#' ,1 )[0 ].strip ()
846+ strippedline = line .split ('#' , 1 )[0 ].strip ()
846847 if not strippedline : continue
847- tup = strippedline .split (':' ,1 )
848- if len (tup ) != 2 :
849- warnings .warn ('Illegal line #%d\n \t %s\n \t in file "%s"' % \
848+ tup = strippedline .split (':' , 1 )
849+ if len (tup ) != 2 :
850+ warnings .warn ('Illegal line #%d\n \t %s\n \t in file "%s"' % \
850851 (cnt , line , fname ))
851852 continue
852853 key , val = tup
853854 key = key .strip ()
854855 val = val .strip ()
855856 if key in rc_temp :
856- warnings .warn ('Duplicate key in file "%s", line #%d' % (fname ,cnt ))
857+ warnings .warn ('Duplicate key in file "%s", line #%d' % \
858+ (fname , cnt ))
857859 rc_temp [key ] = (val , line , cnt )
858860
859- ret = RcParams ([ (key , default ) for key , (default , converter ) in \
860- defaultParams .iteritems () ])
861+ ret = RcParams ([(key , default ) for key , (default , _ ) in \
862+ defaultParams .iteritems ()])
861863
862864 for key in ('verbose.level' , 'verbose.fileo' ):
863865 if key in rc_temp :
@@ -1033,20 +1035,20 @@ class rc_context(object):
10331035
10341036 This allows one to do::
10351037
1036- >>> with mpl.rc_context(fname='screen.rc'):
1037- ... plt.plot(x, a)
1038- ... with mpl.rc_context(fname='print.rc'):
1039- ... plt.plot(x, b)
1040- ... plt.plot(x, c)
1038+ with mpl.rc_context(fname='screen.rc'):
1039+ plt.plot(x, a)
1040+ with mpl.rc_context(fname='print.rc'):
1041+ plt.plot(x, b)
1042+ plt.plot(x, c)
10411043
10421044 The 'a' vs 'x' and 'c' vs 'x' plots would have settings from
10431045 'screen.rc', while the 'b' vs 'x' plot would have settings from
10441046 'print.rc'.
10451047
10461048 A dictionary can also be passed to the context manager::
10471049
1048- >>> with mpl.rc_context(rc={'text.usetex': True}, fname='screen.rc'):
1049- ... plt.plot(x, a)
1050+ with mpl.rc_context(rc={'text.usetex': True}, fname='screen.rc'):
1051+ plt.plot(x, a)
10501052
10511053 The 'rc' dictionary takes precedence over the settings loaded from
10521054 'fname'. Passing a dictionary only is also valid.
@@ -1133,7 +1135,7 @@ def use(arg, warn=True, force=False):
11331135 reload (sys .modules ['matplotlib.backends' ])
11341136
11351137def get_backend ():
1136- "Returns the current backend."
1138+ """Return the name of the current backend."" "
11371139 return rcParams ['backend' ]
11381140
11391141def interactive (b ):
0 commit comments