o
    g                     @   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d ddZdd Zejd!ddZdd Z dd Z!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)_api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%   S/home/ubuntu/cloudmapper/venv/lib/python3.10/site-packages/matplotlib/style/core.py _remove_blacklisted_style_params-   s   r'   c                 C   s   t jt| |d d S )Nr"   )mplrcParamsupdater'   )r!   r"   r%   r%   r&   _apply_style:   s   r,   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>e   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)r3   r4   r   hasattrr,   r   'suppress_matplotlib_deprecation_warningr   r	   r   IOErrorr    )stylestylesrcerrr%   r8   r&   r   >   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   )r@   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   rI   c                  c   s:    t D ]} tj| } tj| rtj| r| V  qd S r2   )USER_LIBRARY_PATHSospath
expanduserexistsisdir)stylelib_pathr%   r%   r&   iter_user_libraries   s   rQ   c                 C   s"   t  D ]}t|}t| | q| S )z0Update style library with user-defined rc files.)rQ   rG   update_nested_dict)r	   rP   rA   r%   r%   r&   update_user_library   s   
rS   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)	style_dirrA   rL   warnswr%   r%   r&   rG      s   rG   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&   rR      s   	rR   c                   C   s    t tatt tdd< dS )zReload the style library.N)rS   _base_libraryr	   sortedr1   r   r%   r%   r%   r&   r
      s   r
   )T)F))__doc__
contextlibloggingrK   pathlibr   rerX   
matplotlibr)   r   r   r   	getLogger__name__r[   __all__rL   joinget_data_pathrH   get_configdirrJ   rW   compileSTYLE_FILE_PATTERNr   r'   r,   r   contextmanagerr   rI   rQ   rS   rG   rR   rg   r	   r   r
   r%   r%   r%   r&   <module>   s>    


>!
