o
    i&!                     @   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 eeZg dZeje	 dZeje	 dgZdZede Zh d	Zd%ddZe
ddd Zd%ddZdd Zej d&ddZ!dd Z"dd Z#dd Z$e
ddd Z%dd  Z&d!d" Z'e" Z(da)g Z*d#d$ Z+e+  dS )'aD  
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)cbookrc_params_from_filercParamsDefault)usecontext	availablelibraryreload_librarystylelibmplstylez([\S]+).%s$>   
date.epochbackend.qt4webagg.portwebagg.addresstk.window_focussavefig.directorydocstring.hardcopyfigure.raise_windowwebagg.port_retrieswebagg.open_in_browserfigure.max_open_warningbackendtoolbardatapathtimezoneinteractivebackend_fallbackTc                 C   s<   i }| D ]}|t v r|rtd| q| | ||< q|S )NzJStyle includes a parameter, '{0}', that is not related to style.  Ignoring)STYLE_BLACKLISTr   _warn_externalformat)dwarnokey r%   P/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/matplotlib/style/core.py _remove_blacklisted_style_params-   s   r'   z3.2c                 C   s   t | duS )z4Return True if the filename looks like a style file.N)STYLE_FILE_PATTERNmatch)filenamer%   r%   r&   is_style_file:   s   r+   c                 C   s   t jt| |d d S )Nr"   )mplrcParamsupdater'   )r!   r"   r%   r%   r&   _apply_style@   s   r0   c                    s   ddd t | ttfst| dr| g}n| } fdd|D }|D ]X} t | ttfs0t|  q"| dkrOt  ttdd W d	   n1 sIw   Y  q"| tv rZtt|   q"zt	| dd
}t| W q" t
yz } zt
d| |d	}~ww 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.                                  |
        +------+-------------------------------------------------------------+

    defaultclassic)mpl20mpl15keysc                 3   s*    | ]}t |tr ||n|V  qd S N)
isinstancestrget).0sstyle_aliasr%   r&   	<genexpr>k   s    "zuse.<locals>.<genexpr>Fr,   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)r7   r8   r   hasattrr0   r   (_suppress_matplotlib_deprecation_warningr   r	   r   IOErrorr    )stylestylesrcerrr%   r<   r&   r   D   s@   


r   Fc                 c   sJ    t   |rt   t|  dV  W d   dS 1 sw   Y  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-   
rc_context
rcdefaultsr   )rD   after_resetr%   r%   r&   r      s   
"r   c                  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   rM   c                  c   s:    t D ]} tj| } tj| rtj| r| V  qd S r6   )USER_LIBRARY_PATHSospath
expanduserexistsisdir)stylelib_pathr%   r%   r&   iter_user_libraries   s   rU   c                 C   s"   t  D ]}t|}t| | q| S )z0Update style library with user-defined rc files.)rU   rK   update_nested_dict)r	   rT   rE   r%   r%   r&   update_user_library   s   
rW   c                 c   sZ    t | D ]$}t j|}t|r*t|}t jt j| |}||	dfV  qdS )z:Yield file path and name of styles in the given directory.   N)
rO   listdirrP   basenamer+   r(   r)   abspathjoingroup)	style_dirrP   r*   r)   r%   r%   r&   iter_style_files   s   
r_   c              	   C   s|   t  }t| dt D ].}tjdd}t|dd||j< W d   n1 s)w   Y  |D ]
}t	d||j
 q0q|S )z3Return dictionary of styles defined in *style_dir*.z*.T)recordFr?   Nz	In %s: %s)dictr   globSTYLE_EXTENSIONwarningscatch_warningsr   stem_logwarningmessage)r^   rE   rP   warnswr%   r%   r&   rK      s   rK   c                 C   s(   |  D ]\}}| |i | q| 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/   )	main_dictnew_dictnamerc_dictr%   r%   r&   rV      s   	rV   c                   C   s    t tatt tdd< dS )zReload the style library.N)rW   _base_libraryr	   sortedr5   r   r%   r%   r%   r&   r
      s   r
   )T)F),__doc__
contextlibloggingrO   pathlibr   rerd   
matplotlibr-   r   r   r   	getLogger__name__rg   __all__rP   r\   get_data_pathrL   get_configdirrN   rc   compiler(   r   r'   
deprecatedr+   r0   r   contextmanagerr   rM   rU   rW   r_   rK   rV   rr   r	   r   r
   r%   r%   r%   r&   <module>   sF    



>!


