U
    
;gU                     @  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eZddddd	d
ZddddddZd%d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   6/tmp/pip-unpacked-wheel-yjz0rwd7/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  s4   zt | W n" tk
r.   t|  dY nX d S )Nz must be bytes-like)
memoryviewr   r   r   r   r	   _check_byteslike$   s    r   intz
int | None)integerlengthr   c                 C  s0   |dkrt d| |p*|  d d p*ddS )Nr   zlength argument can't be 0         big)
ValueErrorto_bytes
bit_length)r   r   r   r   r	   int_to_bytes+   s     r    c                   @  s   e Zd ZdS )InterfaceNotImplementedNr   r   r   r   r	   r!   3   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__8   s    z_DeprecatedValue.__init__N)r   r   r   r(   r   r   r   r	   r"   7   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'   r*   	__class__r   r	   r(   ?   s    z _ModuleWithDeprecations.__init__r
   r#   )attrr   c                 C  s4   t | j|}t|tr0tj|j|jdd |j}|S N   )
stacklevel)	getattrr+   r   r"   warningswarnr$   r&   r   r'   r0   objr   r   r	   __getattr__C   s
    
z#_ModuleWithDeprecations.__getattr__r   )r0   r   r   c                 C  s   t | j|| d S r%   )setattrr+   )r'   r0   r   r   r   r	   __setattr__J   s    z#_ModuleWithDeprecations.__setattr__c                 C  s:   t | j|}t|tr*tj|j|jdd t| j| d S r1   )	r4   r+   r   r"   r5   r6   r$   r&   delattrr7   r   r   r	   __delattr__M   s    
z#_ModuleWithDeprecations.__delattr__ztyping.Sequence[str]r   c                 C  s   dt | jS )Nr+   )r+   )dirr+   r'   r   r   r	   __dir__T   s    z_ModuleWithDeprecations.__dir__)	r   r   r   r(   r9   r;   r=   rA   __classcell__r   r   r.   r	   r)   >   s
   r)   r#   ztype[Warning]z
str | None)r   module_namer$   r&   r   r   c                 C  sJ   t j| }t|ts&t| t j|< }t| ||}|d k	rFt||| |S r%   )sysmodulesr   r)   r"   r:   )r   rC   r$   r&   r   r*   Zdvr   r   r	   
deprecatedX   s    

rF   ztyping.Callableproperty)funcr   c                   s.   d  t  dd fdd}t|S )NZ_cached_r#   )instancec                   s0   t |  }|k	r|S | }t|  | |S r%   )r4   r:   )rI   cacheresultZcached_namerH   sentinelr   r	   innerm   s    zcached_property.<locals>.inner)r#   rG   )rH   rN   r   rL   r	   cached_propertyi   s    
rO   c                   @  s(   e Zd ZddddZd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_r@   r   r   r	   __repr__{   s    zEnum.__repr__c                 C  s   | j j d| j S )NrR   )r/   r   rT   r@   r   r   r	   __str__~   s    zEnum.__str__N)r   r   r   rV   rW   r   r   r   r	   rP   z   s   rP   )N)N)
__future__r   enumrD   typestypingr5   UserWarningr   ZDeprecatedIn36ZDeprecatedIn37ZDeprecatedIn40ZDeprecatedIn41ZDeprecatedIn42ZDeprecatedIn43r   r   r    	Exceptionr!   r"   
ModuleTyper)   rF   rO   rP   r   r   r   r	   <module>   s,    