o
    u#g!                  
   @   s0  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ejdkr(ddl	m
Z n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_librarystylelibmplstyle>   
date.epoch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timezoneinteractivebackend_fallback
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|  } n4d| v r| 	d\}}}zt
|| 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defaultclassic)mpl20mpl15c                 S   s   i | ]}|t vr|t| qS  )STYLE_BLACKLISTr   ).0kr&   r&   z/var/www/static.ux5.de/https/Moving-Object-Detection-with-OpenCV/env/lib/python3.10/site-packages/matplotlib/style/core.py
<dictcomp>u   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   'suppress_matplotlib_deprecation_warningr   r   
rpartitionimportlib_resourcesfilesSTYLE_EXTENSIONr   ModuleNotFoundErrorOSError	TypeErrorr'   warn_externalmplrcParamsupdate)stylestylesstyle_aliaspkg_namepathexcerrfilteredr)   r&   r&   r*   r	   1   sZ   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:   
rc_context
rcdefaultsr	   )r=   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osrC   
expanduserUSER_LIBRARY_PATHSread_style_directoryupdate_nested_dict)r   stylelib_pathr>   r&   r&   r*   update_user_library   s   rQ   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   globr5   warningscatch_warningsr   stem_logwarningmessage)	style_dirr>   rC   warnswr&   r&   r*   rN      s   rN   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_dictrB   rc_dictr&   r&   r*   rO      s   	rO   c                   C   s.   t   t tt tt  tdd< dS )zReload the style library.N)r   clearr<   rQ   _base_librarysortedr!   r   r&   r&   r&   r*   r      s   r   )F).__doc__
contextlibloggingrK   pathlibr   sysrU   version_infoimportlib.resources	resourcesr3   
matplotlibr:   r   r   r   r   	getLogger__name__rX   __all__rC   joinget_data_pathBASE_LIBRARY_PATHget_configdirrM   r5   r'   SubstitutionrJ   formatre   r.   lowerr	   contextmanagerr
   rQ   rN   rO   rd   r   r   r   r&   r&   r&   r*   <module>   s@    


f+
