3
ãde�  ã               @   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Z
eeddœdd„Zeeddœdd„Zdeeje ed	œd
d„Zejejeef dœdd„ZG dd„ deƒZG dd„ dƒZG dd„ dejƒZdeeeeje eje edœdd„Zejedœdd„Z G dd„ de j!ƒZ!dS )é    Nc               @   s   e Zd ZdS )ÚCryptographyDeprecationWarningN)Ú__name__Ú
__module__Ú__qualname__© r   r   úI/var/www/agendate/envp3/lib/python3.6/site-packages/cryptography/utils.pyr      s   r   )ÚnameÚvalueÚreturnc             C   s   t |tƒst| › d�ƒ‚d S )Nz must be bytes)Ú
isinstanceÚbytesÚ	TypeError)r   r	   r   r   r   Ú_check_bytes   s    
r   c             C   s4   yt |ƒ W n" tk
r.   t| › d�ƒ‚Y nX d S )Nz must be bytes-like)Ú
memoryviewr   )r   r	   r   r   r   Ú_check_byteslike!   s    r   )ÚintegerÚlengthr
   c             C   s    | j |p| jƒ d d pddƒS )Né   é   é   Úbig)Úto_bytesÚ
bit_length)r   r   r   r   r   Úint_to_bytes(   s    r   )Úobjr
   c             C   s2   ddl m} |jj| ƒ}t|jjd|ƒƒt|ƒfS )Nr   )Ú_opensslZ	uintptr_t)Z"cryptography.hazmat.bindings._rustr   ÚffiÚfrom_bufferÚintÚcastÚlen)r   r   Úbufr   r   r   Ú_extract_buffer_length.   s    r"   c               @   s   e Zd ZdS )ÚInterfaceNotImplementedN)r   r   r   r   r   r   r   r#   5   s   r#   c               @   s   e Zd Zeedœdd„ZdS )Ú_DeprecatedValue)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   ÚobjectÚstrr(   r   r   r   r   r$   9   s   r$   c                   sj   e Zd Zejdœ‡ fdd„Zeedœdd„Zeeddœd	d
„Z	eddœdd„Z
eje dœdd„Z‡  ZS )Ú_ModuleWithDeprecations)Úmodulec                s   t ƒ j|jƒ || jd< d S )NÚ_module)Úsuperr(   r   Ú__dict__)r'   r,   )Ú	__class__r   r   r(   A   s    z _ModuleWithDeprecations.__init__)Ú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'   r1   r   r   r   r   Ú__getattr__E   s
    
z#_ModuleWithDeprecations.__getattr__N)r1   r	   r
   c             C   s   t | j||ƒ d S )N)Úsetattrr-   )r'   r1   r	   r   r   r   Ú__setattr__L   s    z#_ModuleWithDeprecations.__setattr__c             C   s:   t | j|ƒ}t|tƒr*tj|j|jdd� t| j|ƒ d S )Nr2   )r3   )	r4   r-   r   r$   r5   r6   r%   r&   Údelattr)r'   r1   r   r   r   r   Ú__delattr__O   s    
z#_ModuleWithDeprecations.__delattr__)r
   c             C   s   dgt | jƒ S )Nr-   )Údirr-   )r'   r   r   r   Ú__dir__V   s    z_ModuleWithDeprecations.__dir__)r   r   r   ÚtypesÚ
ModuleTyper(   r*   r)   r7   r9   r;   ÚtypingÚSequencer=   Ú__classcell__r   r   )r0   r   r+   @   s
   r+   )r	   Úmodule_namer%   r&   r   r
   c             C   sJ   t j| }t|tƒs&t|ƒ t j|< }t| ||ƒ}|d k	rFt|||ƒ |S )N)ÚsysÚmodulesr   r+   r$   r8   )r	   rC   r%   r&   r   r,   Zdvr   r   r   Ú
deprecatedZ   s    

rF   )Úfuncr
   c                s.   dˆ› �‰ t ƒ ‰t dœ‡ ‡‡fdd„}t|ƒS )NZ_cached_)Úinstancec                s0   t | ˆ ˆƒ}|ˆk	r|S ˆ| ƒ}t| ˆ |ƒ |S )N)r4   r8   )rH   ÚcacheÚresult)Úcached_namerG   Úsentinelr   r   Úinnero   s    zcached_property.<locals>.inner)r)   Úproperty)rG   rM   r   )rK   rG   rL   r   Úcached_propertyk   s    
rO   c               @   s(   e Zd Zedœdd„Zedœdd„ZdS )ÚEnum)r
   c             C   s    d| j j› d| j› d| j›d�S )Nú<Ú.z: ú>)r0   r   Ú_name_Ú_value_)r'   r   r   r   Ú__repr__}   s    zEnum.__repr__c             C   s   | j j› d| j› �S )NrR   )r0   r   rT   )r'   r   r   r   Ú__str__€   s    zEnum.__str__N)r   r   r   r*   rV   rW   r   r   r   r   rP   |   s   rP   )N)N)"ÚenumrD   r>   r@   r5   ÚUserWarningr   ZDeprecatedIn36ZDeprecatedIn37ZDeprecatedIn39ZDeprecatedIn40r*   r   r   r   r   ÚOptionalr   ÚAnyÚTupler"   Ú	Exceptionr#   r$   r?   r+   r)   ÚTypeÚWarningrF   ÚCallablerN   rO   rP   r   r   r   r   Ú<module>   s(   