a
   ]بLj                   @   s  d dl Z d dlZd dlZd dlZd dlZG dd deZeZeZeZ	e
edddZe
edddZe
d	d
dZdd Zdd Zd$eeje edddZG dd deZdd ZddddZG dd deZG dd deZdd  Zd!d" Zeejed#e	ZdS )%    Nc                   @   s   e Zd ZdS )CryptographyDeprecationWarningN__name__
__module____qualname__ r   r   6/usr/lib/python3.9/site-packages/cryptography/utils.pyr      s   r   namevaluec                 C   s   t |tstd| d S )Nz{} must be bytes)
isinstancebytes	TypeErrorformatr	   r   r   r   _check_bytes   s    
r   c                 C   s2   zt | W n  ty,   td| Y n0 d S )Nz{} must be bytes-like)
memoryviewr   r   r	   r   r   r   _check_byteslike    s    r   r
   c                    s   t  fddS )Nc                    s
   t |  S N)getattrselfr   r   r   <lambda>(       z$read_only_property.<locals>.<lambda>)propertyr   r   r   r   read_only_property'   s    r   c                    s   dd fdd
}|S )NFcheck_annotationsc                   s   t  | |d  |  | S Nr   verify_interfaceregisterklassr   ifacer   r   register_decorator,   s    
z.register_interface.<locals>.register_decoratorr   )r%   r&   r   r$   r   register_interface+   s    r'   c                    s   dd fdd
}|S )NFr   c                   s    rt  | |d  |  | S r   r   r"   r%   	predicater   r   r&   5   s    
z1register_interface_if.<locals>.register_decoratorr   )r)   r%   r&   r   r(   r   register_interface_if4   s    r*   )integerlengthreturnc                 C   s    |  |p|  d d pddS )N         Zbig)to_bytes
bit_length)r+   r,   r   r   r   int_to_bytes>   s    r3   c                   @   s   e Zd ZdS )InterfaceNotImplementedNr   r   r   r   r   r4   D   s   r4   c                 C   s   t dd | j D S )Nc                 S   s   g | ]}|j tjjd qS ))
annotation)replaceinspectZ	Parameterempty).0Zparamr   r   r   
<listcomp>J   s   z$strip_annotation.<locals>.<listcomp>)r7   Z	Signature
parametersvalues)	signaturer   r   r   strip_annotationH   s
    r>   Fr   c                C   s   | j D ]}t||s$td||tt| |tjr8qt	t| |}t	t||}|rf||k}nt
|t
|k}|std||||qd S )Nz{} is missing a {!r} methodzK{}.{}'s signature differs from the expected. Expected: {!r}. Received: {!r})__abstractmethods__hasattrr4   r   r   r   abcabstractpropertyr7   r=   r>   )r%   r#   r   methodZsigactualokr   r   r   r    Q   s$    



r    c                   @   s   e Zd Zdd ZdS )_DeprecatedValuec                 C   s   || _ || _|| _d S r   )r   messagewarning_class)r   r   rG   rH   r   r   r   __init__h   s    z_DeprecatedValue.__init__N)r   r   r   rI   r   r   r   r   rF   g   s   rF   c                   @   s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )_ModuleWithDeprecationsc                 C   s   || j d< d S N_module)__dict__)r   moduler   r   r   rI   o   s    z _ModuleWithDeprecations.__init__c                 C   s4   t | j|}t|tr0tj|j|jdd |j}|S N   )
stacklevel)	r   rL   r   rF   warningswarnrG   rH   r   r   attrobjr   r   r   __getattr__r   s
    
z#_ModuleWithDeprecations.__getattr__c                 C   s   t | j|| d S r   )setattrrL   )r   rU   r   r   r   r   __setattr__y   s    z#_ModuleWithDeprecations.__setattr__c                 C   s:   t | j|}t|tr*tj|j|jdd t| j| d S rO   )	r   rL   r   rF   rR   rS   rG   rH   delattrrT   r   r   r   __delattr__|   s    
z#_ModuleWithDeprecations.__delattr__c                 C   s   dgt | j S rK   )dirrL   r   r   r   r   __dir__   s    z_ModuleWithDeprecations.__dir__N)r   r   r   rI   rW   rY   r[   r]   r   r   r   r   rJ   n   s
   rJ   c                 C   s.   t j| }t|ts"t|t j|< t| ||S r   )sysmodulesr   rJ   rF   )r   Zmodule_namerG   rH   rN   r   r   r   
deprecated   s    


r`   c                    s(   d  t  fdd}t|S )Nz
_cached_{}c                    s0   t |  }|ur|S | }t|  | |S r   )r   rX   )instancecacheresultZcached_namefuncsentinelr   r   inner   s    zcached_property.<locals>.inner)r   objectr   )re   rg   r   rd   r   cached_property   s    
ri   z8int_from_bytes is deprecated, use int.from_bytes instead)N) rA   r7   r^   typingrR   UserWarningr   ZPersistentlyDeprecated2017ZPersistentlyDeprecated2019ZDeprecatedIn34strr   r   r   r   r'   r*   intOptionalr3   	Exceptionr4   r>   r    rh   rF   rJ   r`   ri   
from_bytesr   Zint_from_bytesr   r   r   r   <module>   s6   	
		