o
    
c                     @   s@  d dl 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
dededdfddZdededdfd	d
Zd&dedeje defddZG dd deZddde jdedefddZG dd dZG dd dejZ	d&dedededeje deje defdd Zd!ejdefd"d#Z G d$d% d%ej!Z!dS )'    Nc                   @      e Zd ZdS )CryptographyDeprecationWarningN__name__
__module____qualname__ r   r   ?/opt/certbot/lib/python3.10/site-packages/cryptography/utils.pyr          r   namevaluereturnc                 C   s   t |tstd| d S )Nz{} must be bytes)
isinstancebytes	TypeErrorformat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   r	   _check_byteslike!   s
   r   integerlengthc                 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   c                   @   r   )InterfaceNotImplementedNr   r   r   r   r	   r   .   r
   r   F)check_annotationsifaceklassr    c                C   s   d S Nr   )r!   r"   r    r   r   r	   verify_interface4   s   r$   c                   @   s   e Zd ZdedefddZdS )_DeprecatedValuer   messagec                 C   s   || _ || _|| _d S r#   )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%   <   s    r%   c                       sr   e Zd Zdejf fddZdedefddZdededd	fd
dZ	dedd	fddZ
deje fddZ  ZS )_ModuleWithDeprecationsmodulec                    s   t  |j || jd< d S N_module)superr)   r   __dict__)r(   r-   	__class__r   r	   r)   D   s   z _ModuleWithDeprecations.__init__attrr   c                 C   s4   t | j|}t|trtj|j|jdd |j}|S N   )
stacklevel)	getattrr/   r   r%   warningswarnr&   r'   r   r(   r4   objr   r   r	   __getattr__H   s
   
z#_ModuleWithDeprecations.__getattr__r   Nc                 C   s   t | j|| d S r#   )setattrr/   )r(   r4   r   r   r   r	   __setattr__O   s   z#_ModuleWithDeprecations.__setattr__c                 C   s:   t | j|}t|trtj|j|jdd t| j| d S r5   )	r8   r/   r   r%   r9   r:   r&   r'   delattrr;   r   r   r	   __delattr__R   s   
z#_ModuleWithDeprecations.__delattr__c                 C   s   dgt | j S r.   )dirr/   r(   r   r   r	   __dir__Y   s   z_ModuleWithDeprecations.__dir__)r   r   r   types
ModuleTyper)   r+   r*   r=   r?   rA   typingSequencerD   __classcell__r   r   r2   r	   r,   C   s    r,   module_namer&   r'   c                 C   sJ   t j| }t|tst| t j|< }t| ||}|d ur#t||| |S r#   )sysmodulesr   r,   r%   r>   )r   rJ   r&   r'   r   r-   dvr   r   r	   
deprecated]   s   

rN   funcc                    s.   d  t dtf fdd}t|S )Nz
_cached_{}instancec                    s0   t |  }|ur|S | }t|  | |S r#   )r8   r>   )rP   cacheresultcached_namerO   sentinelr   r	   innerr   s   zcached_property.<locals>.inner)r   r*   property)rO   rV   r   rS   r	   cached_propertyn   s   
rX   c                   @   s(   e Zd ZdefddZdefddZdS )Enumr   c                 C   s    d| j j d| j d| jdS )N<.z: >)r3   r   _name__value_rC   r   r   r	   __repr__   s    zEnum.__repr__c                 C   s   | j j d| j S )Nr[   )r3   r   r]   rC   r   r   r	   __str__   s   zEnum.__str__N)r   r   r   r+   r_   r`   r   r   r   r	   rY      s    rY   r#   )"abcenumrK   rE   rG   r9   UserWarningr   DeprecatedIn36DeprecatedIn37DeprecatedIn39r+   r   r   r   intOptionalr   	Exceptionr   ABCMetar*   boolr$   r%   rF   r,   TypeWarningrN   CallablerW   rX   rY   r   r   r   r	   <module>   sP   

