o
    j                   
   @   s  d Z ddl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	mZ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h dZed	ed
jeeej ddd Z!ej"dddZ#dd Z$dd Z%dd Z&e%eZ'i Z(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)_api
_docstring_rc_params_in_filercParamsDefault)usecontext	availablelibraryreload_libraryZstylelibZmplstyle>   zsavefig.directorytimezonezfigure.raise_windowztk.window_focusZtoolbarzdocstring.hardcopyzwebagg.addresszfigure.max_open_warningZbackend_fallbackbackendinteractivez
date.epochzwebagg.portzwebagg.port_retrieszwebagg.open_in_browser
z- {})keyc                 C   s  t | ttfst| dr| g}n| }ddd}|D ]} t | tr|| | } | dkrFt  dd tD } W d   n1 s@w   Y  n>| tv rOt|  } n5d| v r| 	d\}}}zt
j|| dt  }t|} W n tttfy } zW Y d}~nd}~ww t | ttfrzt| } W n ty } zt| d	|d}~ww i }	| D ]}
|
tv rtd
|
d q| |
 |	|
< qtj|	 q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
            - One of the style names in `.style.available` (a builtin style or
              a style installed in the user library path).

            - A dotted name of the form "package.style_name"; in that case,
              "package" should be an importable Python package name, e.g. at
              ``/path/to/package/__init__.py``; the loaded style file is
              ``/path/to/package/style_name.mplstyle``.  (Style files in
              subpackages are likewise supported.)

            - The path or URL to a style file, which gets loaded by
              `.rc_params_from_file`.

        dict
            A mapping of key/value pairs for `matplotlib.rcParams`.

        Path
            The path to a style file, which gets loaded by
            `.rc_params_from_file`.

        list
            A list of style specifiers (str, Path or dict), which are 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
    keysdefaultZclassic)Zmpl20Zmpl15c                 S   s   i | ]}|t vr|t| qS  )STYLE_BLACKLISTr   ).0kr   r   V/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/matplotlib/style/core.py
<dictcomp>n   s    zuse.<locals>.<dictcomp>N.z is not a valid package style, path of style file, URL of style file, or library style name (library styles are listed in `style.available`)zStyle includes a parameter, z9, that is not related to style.  Ignoring this parameter.)
isinstancestrr   hasattrgetr   Z'suppress_matplotlib_deprecation_warningr   r
   
rpartition	importlib	resourcesfilesSTYLE_EXTENSIONr   ModuleNotFoundErrorOSError	TypeErrorr   Zwarn_externalmplZrcParamsupdate)stylestylesZstyle_aliaspkg_namepathexcerrfilteredr   r   r   r   r   *   sV   4




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
            - One of the style names in `.style.available` (a builtin style or
              a style installed in the user library path).

            - A dotted name of the form "package.style_name"; in that case,
              "package" should be an importable Python package name, e.g. at
              ``/path/to/package/__init__.py``; the loaded style file is
              ``/path/to/package/style_name.mplstyle``.  (Style files in
              subpackages are likewise supported.)

            - The path or URL to a style file, which gets loaded by
              `.rc_params_from_file`.
        dict
            A mapping of key/value pairs for `matplotlib.rcParams`.

        Path
            The path to a style file, which gets loaded by
            `.rc_params_from_file`.

        list
            A list of style specifiers (str, Path or dict), which are 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   )r(   Zafter_resetr   r   r   r      s   
%"r   c                 C   s*   t tjjtD ]}t|}t| | q| S )z0Update style library with user-defined rc files.)maposr-   
expanduserUSER_LIBRARY_PATHSread_style_directoryupdate_nested_dict)r
   Zstylelib_pathr)   r   r   r   update_user_library   s   r7   c              	   C   sx   t  }t| dt D ],}tjdd}t|||j< W d   n1 s'w   Y  |D ]
}t	d||j
 q.q|S )z3Return dictionary of styles defined in *style_dir*.z*.T)recordNz	In %s: %s)dictr   globr"   warningscatch_warningsr   stem_logwarningmessage)Z	style_dirr)   r-   Zwarnswr   r   r   r5      s   r5   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'   )Z	main_dictZnew_dictr,   Zrc_dictr   r   r   r6      s   	r6   c                   C   s.   t   t tt tt  tdd< dS )zReload the style library.N)r
   clearr'   r7   _base_librarysortedr   r	   r   r   r   r   r      s   r   )F)+__doc__
contextlibimportlib.resourcesr   loggingr2   pathlibr   r;   Z
matplotlibr&   r   r   r   r   	getLogger__name__r>   __all__r-   joinZget_data_pathZBASE_LIBRARY_PATHZget_configdirr4   r"   r   ZSubstitutionr1   formatrF   r   lowerr   contextmanagerr   r7   r5   r6   rE   r
   r	   r   r   r   r   r   <module>   s:    

e+
