
    hw<                     P    S SK Jr  S SKr " S S\5      r " S S5      r\" 5       rg)    )EnumNc                        \ rS rSrSrSrSrSrg)BackendFilter   zl
Filter used with :meth:`~matplotlib.backends.registry.BackendRegistry.list_builtin`

.. versionadded:: 3.9
r       N)__name__
__module____qualname____firstlineno____doc__INTERACTIVENON_INTERACTIVE__static_attributes__r       N/var/www/html/env/lib/python3.13/site-packages/matplotlib/backends/registry.pyr   r      s    
 KOr   r   c            
          \ rS rSrSr0 SS_SS_SS_SS_S	S	_S
S
_SS
_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSSSSSSS.ErSSSS	SSSSSS.	rS rS rS r	S  r
S! rS" rS# rS$ rS% rS& rS.S( jrS) rS* rS+ rS, rS-rg')/BackendRegistry   a  
Registry of backends available within Matplotlib.

This is the single source of truth for available backends.

All use of ``BackendRegistry`` should be via the singleton instance
``backend_registry`` which can be imported from ``matplotlib.backends``.

Each backend has a name, a module name containing the backend code, and an
optional GUI framework that must be running if the backend is interactive.
There are three sources of backends: built-in (source code is within the
Matplotlib repository), explicit ``module://some.backend`` syntax (backend is
obtained by loading the module), or via an entry point (self-registering
backend in an external package).

.. versionadded:: 3.9
gtk3agggtk3	gtk3cairogtk4agggtk4	gtk4cairomacosxnbaggnotebookqtaggqtqtcairoqt5aggqt5qt5cairotkaggtktkcairowebaggwxwxaggwxcairoheadless)aggcairopdfpgfpssvgtemplater-   )	r   r   r,   r   r    r#   qt6r&   r)   c                 2    SU l         0 U l        SS0U l        g )NFr   r   )_loaded_entry_points_backend_to_gui_framework_name_to_moduleselfs    r   __init__BackendRegistry.__init__M   s%    $)! *,&  
r   c                     UR                  S5      (       a  USS  $ UR                  5       nU R                  R                  X5      nUR                  S5      (       a  USS  $ SU 3$ )N	module://	   zmatplotlib.backends.backend_)
startswithlowerr8   get)r:   backends     r   _backend_module_name$BackendRegistry._backend_module_name_   sq    k**12; --/ &&**7<&11+>> 	?3G9=	?r   c                 $    U R                  5         g N)r;   r9   s    r   _clearBackendRegistry._clearm   s    r   c                 x    U R                   (       d)  U R                  5       nU R                  U5        SU l         g g )NT)r6   _read_entry_points _validate_and_store_entry_points)r:   entriess     r   _ensure_entry_points_loaded+BackendRegistry._ensure_entry_points_loadedq   s4    ((--/G11':(,D% )r   c                 f    U R                  U5      nUR                  nUR                  =(       d    S$ )Nr,   )load_backend_moduleFigureCanvasrequired_interactive_framework)r:   rC   modulecanvas_classs       r   _get_gui_framework_by_loading-BackendRegistry._get_gui_framework_by_loadingx   s0     ))'2**::HjHr   c                   ^ SS K Jm  TR                  SS9nU Vs/ s H  o"R                  UR                  4PM     nnU4S jnU Vs/ s H  o"S   PM	     nnSU;  a  U" USSS/S5        S	U;  a  U" US	S
S	S/S5        U$ s  snf s  snf )Nr   zmatplotlib.backend)groupc                    > SSK Jn   TR                  U5      nU" U5      U:  a  U H  nU R                  Xt45        M     g g ! TR                   a     g f = f)Nr   )_parse_to_version_info)
matplotlibr[   versionappendPackageNotFoundError)	rM   module_namethreshold_versionnamestargetr[   module_versionnameims	           r    backward_compatible_entry_pointsLBackendRegistry._read_entry_points.<locals>.backward_compatible_entry_points   s_    9!#K!8).9<MM %~6 !& N ** s   8A AAinlinematplotlib_inline)r   r      z matplotlib_inline.backend_inlineipympl)r   r?      widgetzipympl.backend_nbagg)importlib.metadatametadataentry_pointsre   value)r:   rq   entryrM   rg   rb   rf   s         @r   rK   "BackendRegistry._read_entry_points   s     	(-AB:FG,JJ,,G
		 (//weqw/5 ,,i(24 5 ,9x.B&( 5 H  0s   !BBc                 P   [        U5       H  u  p#UR                  5       nUR                  S5      (       a  [        SU S35      eX R                  ;   a  [        SU S35      eX R
                  ;   a  [        SU S35      eSU-   U R                  U'   SU R
                  U'   M     g )Nr>   zEntry point name 'z' cannot start with 'module://'z' is a built-in backendz' duplicatedunknown)setrA   r@   RuntimeError!_BUILTIN_BACKEND_TO_GUI_FRAMEWORKr7   r8   )r:   rM   re   rT   s       r   rL   0BackendRegistry._validate_and_store_entry_points   s      LLD::<D{++"(.MNP P==="%7v=T#UVV555"%7v\#JKK)4v)=D  &3<D**40 )r   c                 T    U R                   R                  UR                  5       5      $ )z
Return the name of the backend corresponding to the specified GUI framework.

Parameters
----------
framework : str
    GUI framework such as "qt".

Returns
-------
str or None
    Backend name or None if GUI framework not recognised.
)_GUI_FRAMEWORK_TO_BACKENDrB   rA   )r:   	frameworks     r   backend_for_gui_framework)BackendRegistry.backend_for_gui_framework   s"     --11)//2CDDr   c                 F   UR                  S5      (       d  UR                  5       nSSS.nUR                  X5      nXR                  ;   d  XR                  ;   a  gUR                  S5      (       a  SU R                  U'   gU R                  5         XR                  ;   a  gg)a6  
Return True if the backend name is valid, False otherwise.

A backend name is valid if it is one of the built-in backends or has been
dynamically added via an entry point. Those beginning with ``module://`` are
always considered valid and are added to the current list of all backends
within this function.

Even if a name is valid, it may not be importable or usable. This can only be
determined by loading and using the backend module.

Parameters
----------
backend : str
    Name of backend.

Returns
-------
bool
    True if backend is valid, False otherwise.
r>   rn   ri   )zmodule://ipympl.backend_nbaggz)module://matplotlib_inline.backend_inlineTrv   F)r@   rA   rB   ry   r7   rN   )r:   rC   backwards_compats      r   is_valid_backend BackendRegistry.is_valid_backend   s    , !!+..mmoG
 .69A
 #&&w8===999k**6?D**73 	((*444r   c                 ^    U R                  5         / U R                  5       QU R                  Q$ )a  
Return list of all known backends.

These include built-in backends and those obtained at runtime either from entry
points or explicit ``module://some.backend`` syntax.

Entry points will be loaded if they haven't been already.

Returns
-------
list of str
    Backend names.
)rN   list_builtinr7   r9   s    r   list_allBackendRegistry.list_all   s/     	((*F""$Ft'E'EFFr   Nc                 b   U[         R                  :X  a7  U R                  R                  5        VVs/ s H  u  p#US:w  d  M  UPM     snn$ U[         R                  :X  a7  U R                  R                  5        VVs/ s H  u  p#US:X  d  M  UPM     snn$ / U R                  Q$ s  snnf s  snnf )a/  
Return list of backends that are built into Matplotlib.

Parameters
----------
filter_ : `~.BackendFilter`, optional
    Filter to apply to returned backends. For example, to return only
    non-interactive backends use `.BackendFilter.NON_INTERACTIVE`.

Returns
-------
list of str
    Backend names.
r,   )r   r   ry   itemsr   )r:   filter_kvs       r   r   BackendRegistry.list_builtin  s     m///"&"H"H"N"N"P ("P$!J "P ( (555"&"H"H"N"N"P ("P$!J "P ( ( 97788((s   B%B%=B+B+c                 T    U R                    Vs/ s H  oS:w  d  M
  UPM     sn$ s  snf )zr
Return list of GUI frameworks used by Matplotlib backends.

Returns
-------
list of str
    GUI framework names.
r,   )r|   )r:   r   s     r   list_gui_frameworks#BackendRegistry.list_gui_frameworks#  s(      99M9a*_9MMMs   	%%c                 P    U R                  U5      n[        R                  " U5      $ )z
Load and return the module containing the specified backend.

Parameters
----------
backend : str
    Name of backend to load.

Returns
-------
Module
    Module containing backend.
)rD   	importlibimport_module)r:   rC   r`   s      r   rQ   #BackendRegistry.load_backend_module.  s%     //8&&{33r   c                 r   [        U[        5      (       a'  UR                  S5      (       d  UR                  5       nOSSKJn  U" 5       nU R                  R                  U5      =(       d    U R                  R                  U5      nUc-  [        U[        5      (       a  UR                  S5      (       a  SnUc<  U R                  (       d+  U R                  5         U R                  R                  U5      nUS:X  a  U R                  U5      nX0R                  U'   Uc  [        SU S35      eXS:w  a  U4$ S4$ )	a  
Return the backend and GUI framework for the specified backend name.

If the GUI framework is not yet known then it will be determined by loading the
backend module and checking the ``FigureCanvas.required_interactive_framework``
attribute.

This function only loads entry points if they have not already been loaded and
the backend is not built-in and not of ``module://some.backend`` format.

Parameters
----------
backend : str or None
    Name of backend, or None to use the default backend.

Returns
-------
backend : str
    The backend name.
framework : str or None
    The GUI framework, which will be None for a backend that is non-interactive.
r>   r   )get_backendNrv   'z"' is not a recognised backend namer,   )
isinstancestrr@   rA   r\   r   ry   rB   r7   r6   rN   rV   rx   )r:   rC   r   guis       r   resolve_backendBackendRegistry.resolve_backend?  s!   . gs##%%k22!--/ /!mG 5599'B ;--11': 	 ;:gs338J8J;8W8WC ;t88,,.0044W=C )44W=C69**73;7)+MNOOj0::d::r   c                     UR                  S5      (       d  UR                  5       nU R                  U5      nUb  X!S:w  a  U4$ S4$  U R                  U5      $ ! [         a    [        SU S35      ef = f)a  
Return the backend and GUI framework for the specified string that may be
either a GUI framework or a backend name, tested in that order.

This is for use with the IPython %matplotlib magic command which may be a GUI
framework such as ``%matplotlib qt`` or a backend name such as
``%matplotlib qtagg``.

This function only loads entry points if they have not already been loaded and
the backend is not built-in and not of ``module://some.backend`` format.

Parameters
----------
gui_or_backend : str or None
    Name of GUI framework or backend, or None to use the default backend.

Returns
-------
backend : str
    The backend name.
framework : str or None
    The GUI framework, which will be None for a backend that is non-interactive.
r>   Nr,   r   z- is not a recognised GUI loop or backend name)r@   rA   r~   r   	Exceptionrx   )r:   gui_or_backendrC   s      r   resolve_gui_or_backend&BackendRegistry.resolve_gui_or_backendu  s    0 ((55+113N 00@
.JNTTPTTT	S''77 	SN##PQS S	Ss   A A3)r7   r6   r8   rG   )r	   r
   r   r   r   ry   r|   r;   rD   rH   rN   rV   rK   rL   r~   r   r   r   r   rQ   r   r   r   r   r   r   r   r      sk   *)6)V) 	6) 	V	)
 	() 	) 	G) 	) 	4) 	%) 	E) 	) 	4) 	() 	d)  	!)" 	4#)$ 1)%: 
!
$?-I#J=*E .`G"90	N4"4;l%Sr   r   )enumr   r   r   r   backend_registryr   r   r   <module>r      s1     D KS KS^ #$ r   