a
    |f                     @  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dd	d
ZddddddZd*ddddddZdddddZG dd deZG dd dZG dd dejZd+ddddddd d!d"Zd#d$d%d&d'ZG d(d) d)ejZdS ),    )annotationsNc                   @  s   e Zd ZdS )CryptographyDeprecationWarningN__name__
__module____qualname__ r   r   LD:\Projects\storyit_web\backend\venv\Lib\site-packages\cryptography/utils.pyr      s   r   strbytesNone)namevaluereturnc                 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  s2   zt | W n  ty,   t|  dY n0 d S )Nz must be bytes-like)
memoryviewr   r   r   r   r	   _check_byteslike"   s    r   intztyping.Optional[int])integerlengthr   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   z
typing.Anyztyping.Tuple[typing.Any, int])objr   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                   @  s   e Zd ZdS )InterfaceNotImplementedNr   r   r   r   r	   r'   6   s   r'   c                   @  s   e Zd ZdddddZdS )_DeprecatedValueobjectr
   )r   messagec                 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   r	   r(   :   s   r(   c                      sb   e Zd Zdd fddZddddd	Zddd
dddZdd
dddZddddZ  ZS )_ModuleWithDeprecationsztypes.ModuleType)modulec                   s   t  |j || jd< d S N_module)superr.   r   __dict__)r-   r0   	__class__r   r	   r.   B   s    z _ModuleWithDeprecations.__init__r
   r)   )attrr   c                 C  s4   t | j|}t|tr0tj|j|jdd |j}|S N   )
stacklevel)	getattrr2   r   r(   warningswarnr*   r,   r   r-   r7   r    r   r   r	   __getattr__F   s
    
z#_ModuleWithDeprecations.__getattr__r   )r7   r   r   c                 C  s   t | j|| d S r+   )setattrr2   )r-   r7   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 r8   )	r;   r2   r   r(   r<   r=   r*   r,   delattrr>   r   r   r	   __delattr__P   s    
z#_ModuleWithDeprecations.__delattr__ztyping.Sequence[str]r   c                 C  s   dgt | j S r1   )dirr2   r-   r   r   r	   __dir__W   s    z_ModuleWithDeprecations.__dir__)	r   r   r   r.   r?   rA   rC   rG   __classcell__r   r   r5   r	   r/   A   s
   r/   r)   ztyping.Type[Warning]ztyping.Optional[str])r   module_namer*   r,   r   r   c                 C  sJ   t j| }t|ts&t| t j|< }t| ||}|d urFt||| |S r+   )sysmodulesr   r/   r(   r@   )r   rI   r*   r,   r   r0   Zdvr   r   r	   
deprecated[   s    

rL   ztyping.Callableproperty)funcr   c                   s.   d  t  dd fdd}t|S )NZ_cached_r)   )instancec                   s0   t |  }|ur|S | }t|  | |S r+   )r;   r@   )rO   cacheresultZcached_namerN   sentinelr   r	   innerp   s    zcached_property.<locals>.inner)r)   rM   )rN   rT   r   rR   r	   cached_propertyl   s    
rU   c                   @  s(   e Zd ZddddZddddZdS )Enumr
   rD   c                 C  s    d| j j d| j d| jdS )N<.z: >)r6   r   _name__value_rF   r   r   r	   __repr__~   s    zEnum.__repr__c                 C  s   | j j d| j S )NrX   )r6   r   rZ   rF   r   r   r	   __str__   s    zEnum.__str__N)r   r   r   r\   r]   r   r   r   r	   rV   }   s   rV   )N)N)
__future__r   enumrJ   typestypingr<   UserWarningr   ZDeprecatedIn36ZDeprecatedIn37ZDeprecatedIn40ZDeprecatedIn41r   r   r   r&   	Exceptionr'   r(   
ModuleTyper/   rL   rU   rV   r   r   r   r	   <module>   s*    