B
    Jd                  @   s~  d Z ddlZddlZddlZddlmZ ddlZddlZddlZ	ddlm
Z
mZmZmZ eeZddddd	gZe
jG d
d dZeje	 dZeje	 dgZdZddddddddddddddddhZd5dd Zd6d!d"Zed#ed$j e!ee"j#d%d&d Z$ej%d7d(dZ&e
'd)d*d+ Z(e
'd)d,d- Z)d.d/ Z*d0d1 Z+d2d3 Z,e+eZ-da.g Z/d4d	 Z0e0  dS )8aD  
Core functions and attributes for the matplotlib style library:

``use``
    Select style sheet to override the current matplotlib settings.
``context``
    Context manager to use a style sheet temporarily.
``available``
    List available style sheets.
``library``
    A dictionary of style names and matplotlib settings.
    N)Path)_api	docstringrc_params_from_filercParamsDefaultusecontext	availablelibraryreload_libraryc               @   s&   e Zd Zejdddedd ZdS )__getattr__z3.5 )obj_typec             C   s   t dt S )Nz([\S]+).%s$)recompileSTYLE_EXTENSION)self r   G/var/www/html/venv/lib/python3.7/site-packages/matplotlib/style/core.py<lambda>        z__getattr__.<lambda>N)__name__
__module____qualname__r   
deprecatedpropertyZSTYLE_FILE_PATTERNr   r   r   r   r      s   r   ZstylelibZmplstyleinteractivebackendzwebagg.portzwebagg.addresszwebagg.port_retrieszwebagg.open_in_browserZbackend_fallbackZtoolbartimezoneZdatapathzfigure.max_open_warningzfigure.raise_windowzsavefig.directoryztk.window_focuszdocstring.hardcopyz
date.epochTc             C   sB   i }x8| D ]0}|t kr.|r:td|d q
| | ||< q
W |S )NzStyle includes a parameter, z9, that is not related to style.  Ignoring this parameter.)STYLE_BLACKLISTr   Zwarn_external)dwarnokeyr   r   r    _remove_blacklisted_style_params0   s    
r$   c             C   s   t jt| |d d S )N)r!   )mplZrcParamsupdater$   )r    r!   r   r   r   _apply_style=   s    r'   
z- {})r#   c                s   ddd t | ttfs"t| dr*| g}n| } fdd|D }x|D ]} t | ttfsbt|  qF| dkrt  ttdd W d	Q R X qF| tkrtt|   qFyt	| dd
}t| W qF t
k
r } zt
d| |W d	d	}~X Y qFX qFW d	S )a  
    Use Matplotlib style settings from a style specification.

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

    .. note::

       This updates the `.rcParams` with the settings from the style.
       `.rcParams` not defined in the style are kept.

    Parameters
    ----------
    style : str, dict, Path 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`.                                      |
        +------+-------------------------------------------------------------+
        | Path | A path-like object which is a path to a style file.         |
        +------+-------------------------------------------------------------+
        | list | A list of style specifiers (str, Path or dict) applied from |
        |      | first to last in the list.                                  |
        +------+-------------------------------------------------------------+

    Notes
    -----
    The following `.rcParams` are not related to style and will be ignored if
    found in a style specification:

    %s
    defaultZclassic)Zmpl20Zmpl15keysc             3   s(   | ] }t |tr ||n|V  qd S )N)
isinstancestrget).0s)style_aliasr   r   	<genexpr>q   s   zuse.<locals>.<genexpr>F)r!   N)use_default_templatez|{!r} not found in the style library and input is not a valid URL or path; see `style.available` for list of available styles)r+   r,   r   hasattrr'   r   Z'suppress_matplotlib_deprecation_warningr   r
   r   IOErrorformat)stylestylesrcerrr   )r0   r   r   A   s,    (



Fc          	   c   s2   t    |rt   t|  dV  W dQ R X dS )a	  
    Context manager for using style settings temporarily.

    Parameters
    ----------
    style : str, dict, Path 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`.                                      |
        +------+-------------------------------------------------------------+
        | Path | A path-like object which is a path to a style file.         |
        +------+-------------------------------------------------------------+
        | list | A list of style specifiers (str, Path 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%   Z
rc_contextZ
rcdefaultsr   )r6   Zafter_resetr   r   r   r      s
    
z3.5c              C   s   t t} | S )z+Load style library defined in this package.)read_style_directoryBASE_LIBRARY_PATH)r
   r   r   r   load_base_library   s    r<   c              c   s<   x6t D ].} tj| } tj| rtj| r| V  qW d S )N)USER_LIBRARY_PATHSospath
expanduserexistsisdir)stylelib_pathr   r   r   iter_user_libraries   s    
rD   c             C   s.   x(t tjjtD ]}t|}t| | qW | S )z0Update style library with user-defined rc files.)mapr>   r?   r@   r=   r:   update_nested_dict)r
   rC   r7   r   r   r   update_user_library   s    rG   c          
   C   sp   t  }xdt| dt D ]L}tjdd}t|dd||j< W dQ R X x|D ]}t	d||j
 qPW qW |S )z3Return dictionary of styles defined in *style_dir*.z*.T)recordF)r2   Nz	In %s: %s)dictr   globr   warningscatch_warningsr   stem_logwarningmessage)Z	style_dirr7   r?   Zwarnswr   r   r   r:      s    
r:   c             C   s,   x&|  D ]\}}| |i | q
W | S )a  
    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.
    )items
setdefaultr&   )Z	main_dictZnew_dictnameZrc_dictr   r   r   rF      s    	rF   c               C   s    t tatt tdd< dS )zReload the style library.N)rG   _base_libraryr
   sortedr*   r	   r   r   r   r   r      s    )T)T)F)1__doc__
contextlibloggingr>   pathlibr   r   rK   Z
matplotlibr%   r   r   r   r   	getLoggerr   rN   __all__Zcaching_module_getattrr   r?   joinZget_data_pathr;   Zget_configdirr=   r   r   r$   r'   ZSubstitutionrE   r5   rV   r,   lowerr   contextmanagerr   r   r<   rD   rG   r:   rF   rU   r
   r	   r   r   r   r   r   <module>   sF   


&F!