a
    ze-                     @   s(   d dl mZ dd ZG dd deZdS )    )WeakSetc                   C   s   t jS N)ABCMeta_abc_invalidation_counter r   r   /usr/lib/python3.9/_py_abc.pyget_cache_token   s    r   c                       sR   e Zd ZdZ fddZdd ZdddZd	d
 Zdd Zdd Z	dd Z
  ZS )r   r   c          	         s   t  j| |||fi |}dd | D }|D ]:}t|dt D ]&}t||d }t|ddrB|| qBq0t||_t |_	t |_
t |_tj|_|S )Nc                 S   s    h | ]\}}t |d dr|qS )__isabstractmethod__F)getattr).0namevaluer   r   r   	<setcomp>&   s   z"ABCMeta.__new__.<locals>.<setcomp>__abstractmethods__r	   F)super__new__itemsr
   setadd	frozensetr   r   _abc_registry
_abc_cache_abc_negative_cacher   r   _abc_negative_cache_version)	mclsr   bases	namespacekwargsclsZ	abstractsbaser   	__class__r   r   r   #   s    
zABCMeta.__new__c                 C   sP   t |tstdt|| r |S t| |r2td| j| t jd7  _|S )NzCan only register classesz'Refusing to create an inheritance cycle   )	
isinstancetype	TypeError
issubclassRuntimeErrorr   r   r   r   )r   subclassr   r   r   register6   s    


zABCMeta.registerNc                 C   s|   t d| j d| j |d t dt  |d | jD ]@}|dr6t| |}t|tr`t	|}t | d||d q6d S )NzClass: .)filezInv. counter: _abc_z: )
print
__module____qualname__r   __dict__
startswithr
   r#   r   r   )r   r+   r   r   r   r   r   _dump_registryH   s    



zABCMeta._dump_registryc                 C   s   | j   d S r   )r   clearr   r   r   r   _abc_registry_clearS   s    zABCMeta._abc_registry_clearc                 C   s   | j   | j  d S r   )r   r3   r   r4   r   r   r   _abc_caches_clearW   s    
zABCMeta._abc_caches_clearc                    sb   |j }| jv rdS t|}||u rH jtjkr>| jv r>dS  |S t fdd||fD S )NTFc                 3   s   | ]}  |V  qd S r   )__subclasscheck__)r   cr4   r   r   	<genexpr>j       z,ABCMeta.__instancecheck__.<locals>.<genexpr>)	r!   r   r$   r   r   r   r   r7   any)r   instancer(   Zsubtyper   r4   r   __instancecheck__\   s    

zABCMeta.__instancecheck__c                 C   s  t |tstd|| jv r dS | jtjk r>t | _tj| _n|| jv rLdS | 	|}|t
ur|rp| j| n| j| |S | t|ddv r| j| dS | jD ] }t||r| j|  dS q|  D ] }t||r| j|  dS q| j| dS )Nz"issubclass() arg 1 must be a classTF__mro__r   )r#   r$   r%   r   r   r   r   r   r   __subclasshook__NotImplementedr   r
   r   r&   __subclasses__)r   r(   okZrclsZsclsr   r   r   r7   l   s8    







zABCMeta.__subclasscheck__)N)__name__r.   r/   r   r   r)   r2   r5   r6   r=   r7   __classcell__r   r   r    r   r      s   
r   N)_weakrefsetr   r   r$   r   r   r   r   r   <module>   s   
