o
    9f                     @  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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	   2lib/python3.10/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
int | Nonec                 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   r!   obj
typing.Any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%   ZffiZfrom_bufferr   cast)r"   r%   bufr	   r	   r
   _extract_buffer_length0   s   r(   c                   @  r   )InterfaceNotImplementedNr   r	   r	   r	   r
   r)   7   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,   r.   r	   r	   r
   __init__<   s   
z_DeprecatedValue.__init__N)r   r+   r,   r   )r   r   r   r0   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)superr0   r   __dict__)r/   r2   	__class__r	   r
   r0   C   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)	getattrr5   r   r*   warningswarnr,   r.   r   r/   r:   r"   r	   r	   r
   __getattr__G   s
   
z#_ModuleWithDeprecations.__getattr__r   r   c                 C  s   t | j|| d S r-   )setattrr5   )r/   r:   r   r	   r	   r
   __setattr__N   s   z#_ModuleWithDeprecations.__setattr__c                 C  s:   t | j|}t|trtj|j|jdd t| j| d S r;   )	r>   r5   r   r*   r?   r@   r,   r.   delattrrA   r	   r	   r
   __delattr__Q   s   
z#_ModuleWithDeprecations.__delattr__typing.Sequence[str]c                 C  s   dgt | jS r4   )dirr5   r/   r	   r	   r
   __dir__X   s   z_ModuleWithDeprecations.__dir__)r2   r3   )r:   r   r   r+   )r:   r   r   r+   r   r   )r:   r   r   r   )r   rG   )	r   r   r   r0   rB   rD   rF   rJ   __classcell__r	   r	   r8   r
   r1   B   s    


r1   r+   module_namer,   r.   type[Warning]
str | Nonec                 C  sJ   t j| }t|tst| t j|< }t| ||}|d ur#t||| |S r-   )sysmodulesr   r1   r*   rC   )r   rL   r,   r.   r   r2   Zdvr	   r	   r
   
deprecated\   s   

rQ   functyping.Callablepropertyc                   s*   d  t  d fdd}t|S )NZ_cached_instancer+   c                   s0   t |  }|ur|S | }t|  | |S r-   )r>   rC   )rU   cacheresultZcached_namerR   Zsentinelr	   r
   innerq   s   zcached_property.<locals>.inner)rU   r+   )r+   rT   )rR   rY   r	   rX   r
   cached_propertym   s   
rZ   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: >)r9   r   _name__value_rI   r	   r	   r
   __repr__   s    zEnum.__repr__c                 C  s   | j j d| j S )Nr]   )r9   r   r_   rI   r	   r	   r
   __str__   s   zEnum.__str__N)r   r   )r   r   r   ra   rb   r	   r	   r	   r
   r[   ~   s    
r[   )r   r   r   r   r   r   r-   )r   r   r   r   r   r   )r"   r#   r   r$   )r   r+   rL   r   r,   r   r.   rM   r   rN   r   r*   )rR   rS   r   rT   )Z
__future__r   enumrO   typestypingr?   UserWarningr   ZDeprecatedIn36ZDeprecatedIn37ZDeprecatedIn40ZDeprecatedIn41ZDeprecatedIn42r   r   r!   r(   	Exceptionr)   r*   
ModuleTyper1   rQ   rZ   r[   r	   r	   r	   r
   <module>   s.   



