
    #Yh'                       d dl mZ d dlZd dlmZ d dlmZ d dlmZm	Z	m
Z
mZmZmZ d dlmZ ej        dk    rd dlmZ nd dlmZ ej        d	k    rd d
lmZ nd d
lmZ erd dlmZ  ed          Z ed          Z ede
def         ef          Z edee	                   Ze
egeee	                  f         ZddZ G d de          Z G d deeef                   Z G d deeef                   Z d Z!dS )     )annotationsN)partial)entry_points)TYPE_CHECKINGAnyCallableGenericTypeVarcast)deprecated_warn)      )TypeIs)r      )TypeAliasType)TracebackTypeTRPlugin.)type_paramsPluginT)boundtptype[T]return#Callable[[object], TypeIs[type[T]]]c                    d fd}|S )zq
    Converts a type to guard function.

    Added for compatibility with original `PluginRegistry` default.
    objobjectr   TypeIs[type[T]]c               $    t          |           S N)
isinstance)r   r   s    dD:\DownLoads\facial_attendance_system-main\venv311\Lib\site-packages\altair/utils/plugin_registry.pyfuncz_is_type.<locals>.func$   s    #r"""    )r   r   r   r     )r   r%   s   ` r$   _is_typer(      s(    # # # # # # Kr&   c                      e Zd Zd Zd ZdS )NoSuchEntryPointc                "    || _         || _        d S r"   )groupname)selfr,   r-   s      r$   __init__zNoSuchEntryPoint.__init__+   s    
			r&   c                &    d| j         d| j        S )NzNo z entry point found in group )r-   r,   r.   s    r$   __str__zNoSuchEntryPoint.__str__/   s    LTYLLdjLLLr&   N)__name__
__module____qualname__r/   r2   r'   r&   r$   r*   r*   *   s7          M M M M Mr&   r*   c                  2    e Zd ZdZdd
ZddZddZddZdS )PluginEnablera%  
    Context manager for enabling plugins.

    This object lets you use enable() as a context manager to
    temporarily enable a given plugin::

        with plugins.enable("name"):
            do_something()  # 'name' plugin temporarily enabled
        # plugins back to original state
    registryPluginRegistry[PluginT, R]r-   stroptionsr   r   Nonec                    || _         || _        || _        |                                | _         | j         j        |fi | d S r"   )r8   r-   r;   
_get_stateoriginal_state_enable)r.   r8   r-   r;   s       r$   r/   zPluginEnabler.__init__?   sP     5=	'..6.A.A.C.Cd..g.....r&   PluginEnabler[PluginT, R]c                    | S r"   r'   r1   s    r$   	__enter__zPluginEnabler.__enter__H   s    r&   typtypevalue	Exception	tracebackr   c                D    | j                             | j                   d S r"   )r8   
_set_stater?   )r.   rD   rF   rH   s       r$   __exit__zPluginEnabler.__exit__K   s!      !455555r&   c                J    t          | j                  j         d| j        dS )Nz.enable())rE   r8   r3   r-   r1   s    r$   __repr__zPluginEnabler.__repr__N   s(    t}%%.FF	FFFFr&   N)r8   r9   r-   r:   r;   r   r   r<   )r   rA   )rD   rE   rF   rG   rH   r   r   r<   r   r:   )r3   r4   r5   __doc__r/   rC   rK   rN   r'   r&   r$   r7   r7   3   st        	 	/ / / /   6 6 6 6G G G G G Gr&   r7   c                      e Zd ZU dZi Zded<   i Zded<   defd#dZd$dZ	d%dZ
d&dZd'dZd(dZ	 d)d*dZed+d            Zed&d            Zd,d!Zd+d"ZdS )-PluginRegistrya  
    A registry for plugins.

    This is a plugin registry that allows plugins to be loaded/registered
    in two ways:

    1. Through an explicit call to ``.register(name, value)``.
    2. By looking for other Python packages that are installed and provide
       a setuptools entry point group.

    When you create an instance of this class, provide the name of the
    entry point group to use::

        reg = PluginRegister("my_entrypoint_group")

    zdict[str, str]entrypoint_err_messagesdict[str, Any]_global_settings entry_point_groupr:   plugin_typeIsPluginr   r<   c                   || _         |  |t          urft          |t                    rQdt          |           j        d}t          |d           t          t          t          |                    | _	        n|| _	        d| _
        d| _        i | _        i | _        | j        j                                        | _        dS )a  
        Create a PluginRegistry for a named entry point group.

        Parameters
        ----------
        entry_point_group: str
            The name of the entry point group.
        plugin_type
            A type narrowing function that will optionally be used for runtime
            type checking loaded plugins.

        References
        ----------
        https://typing.readthedocs.io/en/latest/spec/narrowing.html
        z<Pass a callable `TypeIs` function to `plugin_type` instead.
z~(plugin_type)

See also:
https://typing.readthedocs.io/en/latest/spec/narrowing.html
https://docs.astral.sh/ruff/rules/assert/z5.4.0)versionNrV   )rW   callabler#   rE   r3   r   r   rY   r(   rX   _active_active_name_plugins_options	__class__rU   copy)r.   rW   rX   msgs       r$   r/   zPluginRegistry.__init__l   s    $ '8"h&&:k4+H+H&=::&= = =  C1111#Hh{.C.CDDD*D)-!#,.(*040O0T0T0V0Vr&   r-   rF   PluginT | Nonec                    || j                             |d          S |                     |          r|| j         |<   |S t          |          j        dt          |           j        }t          |          )a(  
        Register a plugin by name and value.

        This method is used for explicit registration of a plugin and shouldn't be
        used to manage entry point managed plugins, which are auto-loaded.

        Parameters
        ----------
        name: str
            The name of the plugin.
        value: PluginType or None
            The actual plugin object to register or None to unregister that plugin.

        Returns
        -------
        plugin: PluginType or None
            The plugin that was registered or unregistered.
        Nz is not compatible with )r_   poprX   rE   r3   	TypeError)r.   r-   rF   rc   s       r$   registerzPluginRegistry.register   sy    & ==$$T4000e$$ 	!"'DM$L%[[)\\T$ZZEX\\CC.. r&   	list[str]c                    t          | j                                                  }t          | j                  }d |D             }|                    |           t          t          |                    S )z:List the names of the registered and entry points plugins.c                    g | ]	}|j         
S r'   r-   ).0eps     r$   
<listcomp>z(PluginRegistry.names.<locals>.<listcomp>   s    000RW000r&   )listr_   keysimportlib_metadata_getrW   extendsortedset)r.   extse_points	more_extss       r$   nameszPluginRegistry.names   sf    DM&&(()))$*@AA00x000	Ic$ii   r&   c                    | j         | j        | j                                        | j                                        | j                                        dS )zCReturn a dictionary representing the current state of the registry.)r]   r^   r_   r`   rU   )r]   r^   r_   rb   r`   rU   r1   s    r$   r>   zPluginRegistry._get_state   sR     | -**,,**,, $ 5 : : < <
 
 	
r&   statec                    t          |                                          h dk    sJ |                                D ]\  }}t          | ||           dS )z Reset the state of the registry.>   r]   r`   r_   r^   rU   N)ru   rq   itemssetattr)r.   r{   keyvals       r$   rJ   zPluginRegistry._set_state   st    5::<<   %
 %
 %
 
 
 
 
  	$ 	$HCD#s####	$ 	$r&   c                   | j         vr	 fdt          | j                  D             \  }nL# t          $ r?}| j        v rt          | j                           |t          | j                  |d }~ww xY wt          t          |                                          }| 	                    |           | _
        | j                  | _        t          |                                          t          | j                                                  z  D ]}|                    |          | j        |<    || _        d S )Nc              3  2   K   | ]}|j         k    |V  d S r"   rl   )rm   rn   r-   s     r$   	<genexpr>z)PluginRegistry._enable.<locals>.<genexpr>   s7        w$ & r&   )r_   rr   rW   
ValueErrorrS   r*   r   r   loadrh   r^   r]   ru   rq   rU   rf   r`   )r.   r-   r;   rn   errrF   r   s    `     r$   r@   zPluginRegistry._enable   sR   t}$$
R   4T5KLL  
  R R R4777$T%A$%GHHcQ*4+A4HHcQ	R
 "'')),,EMM$&&& }T*w||~~&&T-B-G-G-I-I)J)JJ 	: 	:C)0S)9)9D!#&&s   "/ 
A8:A33A8N
str | Noner;   r   rA   c                0    || j         }t          | |fi |S )a&  
        Enable a plugin by name.

        This can be either called directly, or used as a context manager.

        Parameters
        ----------
        name : string (optional)
            The name of the plugin to enable. If not specified, then use the
            current active name.
        **options :
            Any additional parameters will be passed to the plugin as keyword
            arguments

        Returns
        -------
        PluginEnabler:
            An object that allows enable() to be used as a context manager
        )activer7   )r.   r-   r;   s      r$   enablezPluginRegistry.enable   s(    , <;DT4337333r&   c                    | j         S )z/Return the name of the currently active plugin.)r^   r1   s    r$   r   zPluginRegistry.active   s       r&   c                    | j         S )z&Return the current options dictionary.)r`   r1   s    r$   r;   zPluginRegistry.options   s     }r&   partial[R] | Plugin[R] | Nonec                "   | j         x}r0|                     |          r| j        rt          |fi | j        n|S | j         @t	          |           j        dt	          | j                   j        d}t          |          t          rt          dS )z#Return the currently active plugin.Nz2 requires all plugins to be callable objects, but z is not callable.)	r]   rX   r`   r   rE   r3   rg   r   NotImplementedError)r.   r%   rc   s      r$   getzPluginRegistry.get  s    L D 	&d&6&6t&<&< 	&59]L74114=111L\%::& H HDL))2H H H  C..  	& &%		& 	&r&   c                j    t          |           j         d| j        d|                                 dS )Nz(active=z, registered=rM   )rE   r3   r   ry   r1   s    r$   rN   zPluginRegistry.__repr__  s4    t**%\\t{\\4::<<\\\\r&   )rW   r:   rX   rY   r   r<   )r-   r:   rF   rd   r   rd   )r   ri   )r   rT   )r{   rT   r   r<   )r-   r:   r   r<   r"   )r-   r   r;   r   r   rA   rO   )r   r   )r3   r4   r5   rP   rS   __annotations__rU   r\   r/   rh   ry   r>   rJ   r@   r   propertyr   r;   r   rN   r'   r&   r$   rR   rR   R   s^         & /10000 (*)))) (*8$W $W $W $W $WL! ! ! !8! ! ! !
 
 
 

$ 
$ 
$ 
$       , "&4 4 4 4 44 ! ! ! X!    X& & & & ] ] ] ] ] ]r&   rR   c                    t                      }t          |d          r|                    |           S |                    | g           S )Nselect)r,   )r   hasattrr   r   )r,   rn   s     r$   rr   rr     sG    	B
 r8 !yyuy%%%vveR   r&   )r   r   r   r   )"
__future__r   sys	functoolsr   importlib.metadatar   typingr   r   r   r	   r
   r   altair.utils.deprecationr   version_infor   typing_extensionsr   typesr   r   r   r   r   r   rY   r(   rG   r*   r7   rR   rr   r'   r&   r$   <module>r      sU   " " " " " " 



       + + + + + + G G G G G G G G G G G G G G G G 4 4 4 4 4 4w((((((w$$$$$$$////// $######GCLLGCLL	x#q&!1t	D	D	D
')6#;
/
/
/VHfVC[112
 
 
 
M M M M My M M MG G G G GGGQJ' G G G>D] D] D] D] D]WWaZ( D] D] D]N	! 	! 	! 	! 	!r&   