o
    e                     @  s   d dl mZ 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Zd/ddZd/ddZd0d1ddZd2ddZG dd deZG dd dZG dd dejZ	d0d3d&d'Zd4d+d,ZG d-d. d.ejZdS )5    )annotationsNc                   @     e Zd ZdS )CryptographyDeprecationWarningN__name__
__module____qualname__ r	   r	   BD:\Projects\ConvertPro\env\Lib\site-packages\cryptography/utils.pyr          r   namestrvaluebytesreturnNonec                 C  s   t |tst|  dd S )Nz must be bytes)
isinstancer   	TypeErrorr   r   r	   r	   r
   _check_bytes   s   
r   c                 C  s,   zt | W d S  ty   t|  dw )Nz must be bytes-like)
memoryviewr   r   r	   r	   r
   _check_byteslike"   s
   r   integerintlengthtyping.Optional[int]c                 C  s    |  |p|  d d pddS )N         big)to_bytes
bit_length)r   r   r	   r	   r
   int_to_bytes)   s   r"   obj
typing.Anytyping.Tuple[typing.Any, int]c                 C  s.   ddl m} |j| }|t|jd|fS )Nr   )_opensslZ	uintptr_t)Z"cryptography.hazmat.bindings._rustr&   ffifrom_bufferr   cast)r#   r&   bufr	   r	   r
   _extract_buffer_length/   s   r+   c                   @  r   )InterfaceNotImplementedNr   r	   r	   r	   r
   r,   6   r   r,   c                   @  s   e Zd ZdddZdS )	_DeprecatedValuer   objectmessager   c                 C  s   || _ || _|| _d S N)r   r/   warning_class)selfr   r/   r1   r	   r	   r
   __init__;   s   
z_DeprecatedValue.__init__N)r   r.   r/   r   )r   r   r   r3   r	   r	   r	   r
   r-   :   s    r-   c                      sF   e Zd Zd fddZdd	d
ZdddZdddZdddZ  ZS )_ModuleWithDeprecationsmoduletypes.ModuleTypec                   s   t  |j || jd< d S N_module)superr3   r   __dict__)r2   r5   	__class__r	   r
   r3   B   s   z _ModuleWithDeprecations.__init__attrr   r   r.   c                 C  s4   t | j|}t|trtj|j|jdd |j}|S N   )
stacklevel)	getattrr8   r   r-   warningswarnr/   r1   r   r2   r=   r#   r	   r	   r
   __getattr__F   s
   
z#_ModuleWithDeprecations.__getattr__r   r   c                 C  s   t | j|| d S r0   )setattrr8   )r2   r=   r   r	   r	   r
   __setattr__M   s   z#_ModuleWithDeprecations.__setattr__c                 C  s:   t | j|}t|trtj|j|jdd t| j| d S r>   )	rA   r8   r   r-   rB   rC   r/   r1   delattrrD   r	   r	   r
   __delattr__P   s   
z#_ModuleWithDeprecations.__delattr__typing.Sequence[str]c                 C  s   dgt | j S r7   )dirr8   r2   r	   r	   r
   __dir__W   s   z_ModuleWithDeprecations.__dir__)r5   r6   )r=   r   r   r.   )r=   r   r   r.   r   r   )r=   r   r   r   )r   rJ   )	r   r   r   r3   rE   rG   rI   rM   __classcell__r	   r	   r;   r
   r4   A   s    


r4   r.   module_namer/   r1   typing.Type[Warning]typing.Optional[str]c                 C  sJ   t j| }t|tst| t j|< }t| ||}|d ur#t||| |S r0   )sysmodulesr   r4   r-   rF   )r   rO   r/   r1   r   r5   Zdvr	   r	   r
   
deprecated[   s   

rT   functyping.Callablepropertyc                   s*   d  t  d fdd}t|S )NZ_cached_instancer.   c                   s0   t |  }|ur|S | }t|  | |S r0   )rA   rF   )rX   cacheresultZcached_namerU   sentinelr	   r
   innerp   s   zcached_property.<locals>.inner)rX   r.   )r.   rW   )rU   r]   r	   r[   r
   cached_propertyl   s   
r^   c                   @  s    e Zd ZdddZdddZdS )	Enumr   r   c                 C  s    d| j j d| j d| jdS )N<.z: >)r<   r   _name__value_rL   r	   r	   r
   __repr__~   s    zEnum.__repr__c                 C  s   | j j d| j S )Nra   )r<   r   rc   rL   r	   r	   r
   __str__   s   zEnum.__str__N)r   r   )r   r   r   re   rf   r	   r	   r	   r
   r_   }   s    
r_   )r   r   r   r   r   r   r0   )r   r   r   r   r   r   )r#   r$   r   r%   )r   r.   rO   r   r/   r   r1   rP   r   rQ   r   r-   )rU   rV   r   rW   )
__future__r   enumrR   typestypingrB   UserWarningr   ZDeprecatedIn36ZDeprecatedIn37ZDeprecatedIn40ZDeprecatedIn41r   r   r"   r+   	Exceptionr,   r-   
ModuleTyper4   rT   r^   r_   r	   r	   r	   r
   <module>   s,   



