σ
 m[c           @` s²  d  d l  m Z m Z m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l	 Z
 d  d l	 m Z m Z d d d d d g Z e j j e
 j   d	  Z e j j e
 j   d	  g Z d
 Z e j d e  Z d d d d d d d d d d d d d d d h Z e d  Z d   Z e d  Z d   Z e j e d   Z d    Z  d!   Z! d"   Z" d#   Z# d$   Z$ d%   Z% e    Z& d a( g  Z) d&   Z* e*   d S('   i    (   t   absolute_importt   divisiont   print_functionN(   t   rc_params_from_filet   rcParamsDefaultt   uset   contextt	   availablet   libraryt   reload_libraryt   stylelibt   mplstyles   ([\S]+).%s$t   interactivet   backends   backend.qt4s   webagg.ports   webagg.addresss   webagg.port_retriess   webagg.open_in_browsert   backend_fallbackt   toolbart   timezonet   datapaths   figure.max_open_warnings   savefig.directorys   tk.window_focuss   docstring.hardcopyc         C` s_   i  } xR |  j    D]D \ } } | t k rM | rW t j d j |   qW q | | | <q W| S(   NsJ   Style includes a parameter, '{0}', that is not related to style.  Ignoring(   t   itemst   STYLE_BLACKLISTt   warningst   warnt   format(   t   dR   t   ot   keyt   val(    (    s4   lib/python2.7/site-packages/matplotlib/style/core.pyt    _remove_blacklisted_style_params,   s    c         C` s   t  j |   d k	 S(   s4   Return True if the filename looks like a style file.N(   t   STYLE_FILE_PATTERNt   matcht   None(   t   filename(    (    s4   lib/python2.7/site-packages/matplotlib/style/core.pyt   is_style_file9   s    c         C` s    t  j j t |  d |  d  S(   NR   (   t   mplt   rcParamst   updateR   (   R   R   (    (    s4   lib/python2.7/site-packages/matplotlib/style/core.pyt   _apply_style>   s    c         ` s  i d d 6d d 6  t  |  t j  s5 t |  d  rA |  g } n |  }   f d   | D } x² | D]ͺ }  t  |  t j  s t |   qd |  d k r¨ t t d t qd |  t k rΕ t t |   qd y  t |  d t } t |  Wqd t	 k
 rt	 d	 j
 |     qd Xqd Wd
 S(   s*  Use matplotlib style settings from a style specification.

    The style name of 'default' is reserved for reverting back to
    the default style settings.

    Parameters
    ----------
    style : str, dict, or list
        A style specification. Valid options are:

        +------+-------------------------------------------------------------+
        | str  | The name of a style or a path/URL to a style file. For a    |
        |      | list of available style names, see `style.available`.       |
        +------+-------------------------------------------------------------+
        | dict | Dictionary with valid key/value pairs for                   |
        |      | `matplotlib.rcParams`.                                      |
        +------+-------------------------------------------------------------+
        | list | A list of style specifiers (str or dict) applied from first |
        |      | to last in the list.                                        |
        +------+-------------------------------------------------------------+


    t   defaultt   mpl20t   classict   mpl15t   keysc         3` s9   |  ]/ } t  | t j  r-   j | |  n | Vq d  S(   N(   t
   isinstancet   sixt   string_typest   get(   t   .0t   s(   t   style_alias(    s4   lib/python2.7/site-packages/matplotlib/style/core.pys	   <genexpr>b   s   R   t   use_default_templates|   {!r} not found in the style library and input is not a valid URL or path; see `style.available` for list of available stylesN(   R*   R+   R,   t   hasattrR$   R   t   FalseR   R   t   IOErrorR   (   t   stylet   stylest   rc(    (   R0   s4   lib/python2.7/site-packages/matplotlib/style/core.pyR   B   s*    

!
c         c` sn   t  j j   } | r" t  j   n  z4 y t |   Wn t  j j |    n Xd VWd t  j j |  Xd S(   sa  Context manager for using style settings temporarily.

    Parameters
    ----------
    style : str, dict, or list
        A style specification. Valid options are:

        +------+-------------------------------------------------------------+
        | str  | The name of a style or a path/URL to a style file. For a    |
        |      | list of available style names, see `style.available`.       |
        +------+-------------------------------------------------------------+
        | dict | Dictionary with valid key/value pairs for                   |
        |      | `matplotlib.rcParams`.                                      |
        +------+-------------------------------------------------------------+
        | list | A list of style specifiers (str or dict) applied from first |
        |      | to last in the list.                                        |
        +------+-------------------------------------------------------------+

    after_reset : bool
        If True, apply style after resetting settings to their defaults;
        otherwise, apply style on top of the current settings.
    N(   R!   R"   t   copyt
   rcdefaultsR   R#   (   R5   t   after_resett   initial_settings(    (    s4   lib/python2.7/site-packages/matplotlib/style/core.pyR   x   s     	c          C` s    t    }  |  j t t   |  S(   s+   Load style library defined in this package.(   t   dictR#   t   read_style_directoryt   BASE_LIBRARY_PATH(   R   (    (    s4   lib/python2.7/site-packages/matplotlib/style/core.pyt   load_base_library   s    	c          c` sS   xL t  D]D }  t j j |   }  t j j |   r t j j |   r |  Vq q Wd  S(   N(   t   USER_LIBRARY_PATHSt   ost   patht
   expandusert   existst   isdir(   t   stylelib_path(    (    s4   lib/python2.7/site-packages/matplotlib/style/core.pyt   iter_user_libraries¦   s    $c         C` s1   x* t    D] } t |  } t |  |  q
 W|  S(   s/   Update style library with user-defined rc files(   RG   R=   t   update_nested_dict(   R   RF   R6   (    (    s4   lib/python2.7/site-packages/matplotlib/style/core.pyt   update_user_library­   s    c         c` s   x} t  j |   D]l } t  j j |  } t |  r t j |  } t  j j t  j j |  |   } | | j	   d f Vq q Wd S(   s:   Yield file path and name of styles in the given directory.i    N(
   RA   t   listdirRB   t   basenameR    R   R   t   abspatht   joint   groups(   t	   style_dirRB   R   R   (    (    s4   lib/python2.7/site-packages/matplotlib/style/core.pyt   iter_style_files΅   s    !c      	   C` s   t    } x| t |   D]n \ } } t j d t   } t | d t | | <Wd QXx. | D]& } d | | j f } t j |  qZ Wq W| S(   s3   Return dictionary of styles defined in `style_dir`.t   recordR1   Ns	   In %s: %s(	   R<   RP   R   t   catch_warningst   TrueR   R3   t   messageR   (   RO   R6   RB   t   namet   warnst   wRT   (    (    s4   lib/python2.7/site-packages/matplotlib/style/core.pyR=   Ώ   s    		c         C` sN   xG t  j |  D]6 \ } } | |  k r< |  | j |  q | |  | <q W|  S(   s  Update nested dict (only level of nesting) with new values.

    Unlike dict.update, this assumes that the values of the parent dict are
    dicts (or dict-like), so you shouldn't replace the nested dict if it
    already exists. Instead you should update the sub-dict.
    (   R+   t	   iteritemsR#   (   t	   main_dictt   new_dictRU   t   rc_dict(    (    s4   lib/python2.7/site-packages/matplotlib/style/core.pyRH   Ξ   s
    c           C` s   t  t  t (a d S(   s   Reload style library.N(   RI   t   _base_libraryR   R   (    (    (    s4   lib/python2.7/site-packages/matplotlib/style/core.pyR	   ζ   s    (+   t
   __future__R    R   R   R+   RA   t   ret
   contextlibR   t
   matplotlibR!   R   R   t   __all__RB   RM   t   get_data_pathR>   t   _get_configdirR@   t   STYLE_EXTENSIONt   compileR   R   RS   R   R    R$   R   t   contextmanagerR3   R   R?   RG   RI   RP   R=   RH   R\   R   R   R   R	   (    (    (    s4   lib/python2.7/site-packages/matplotlib/style/core.pyt   <module>   sB   			6&				
				