o
    QDih                     @  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mZ d dlmZ d dlm	Z	 d dlm
Z
 d dlmZ d dlmZ d d	lmZ d dlZd dlZd d
lmZ zd dlmZ W n eye   d dlmZ Y nw dZedZe
dZd)ddZd*ddZd+ddZed,ddZefd-d#d$ZG d%d& d&eZ G d'd( d(e!Z"dS ).    )annotationsN)	lru_cache)Any)Callable)TypeVar)urljoin)pathname2url)urlopen)	ParamSpec)CSafeLoader)
SafeLoaderg      ?PTmethodCallable[P, T]returnc                   s   t  d	 fdd}|S )
NargsP.argskwargsP.kwargsr   r   c               
     sF   z | i |W S  t y" } ztt||t d d }~ww )N   )	ExceptionSwaggerValidationErrorstrwith_tracebacksysexc_info)r   r   er    V/var/www/Datamplify/venv/lib/python3.10/site-packages/swagger_spec_validator/common.pywrapper   s   zwrap_exception.<locals>.wrapper)r   r   r   r   r   r   )	functoolswraps)r   r!   r   r   r    wrap_exception   s   r$   	file_pathr   c                 C  s   t dttj| S )Nzfile://)r   r   ospathabspathr%   r   r   r    get_uri_from_file_path)   s   r*   dict[str, Any]c                 C  s   t t| S )z
    Utility method for reading a JSON/YAML file and converting it to a Python dictionary
    :param file_path: path of the file to read

    :return: Python dictionary representation of the JSON file
    :rtype: dict
    )read_urlr*   r)   r   r   r    	read_file-   s   r-   resource_pathtuple[dict[str, Any], str]c                 C  sH   t d|  }t |}t||fW  d    S 1 sw   Y  d S )Nswagger_spec_validator)importlib_resourcesfilesas_filer-   )r.   refr'   r   r   r    read_resource_file8   s   
$r5   urltimeoutfloatc                 C  sN   t t| |d}tj| dtdW  d    S 1 s w   Y  d S )N)r7   zutf-8)Loader)
contextlibclosingr	   yamlloadreaddecoder   )r6   r7   fhr   r   r    r,   ?   s   $r,   c                   @     e Zd ZdZdS )r   z/Exception raised in case of a validation error.N__name__
__module____qualname____doc__r   r   r   r    r   E       r   c                   @  rA   )SwaggerValidationWarningz!Warning raised during validation.NrB   r   r   r   r    rH   K   rG   rH   )r   r   r   r   )r%   r   r   r   )r%   r   r   r+   )r.   r   r   r/   )r6   r   r7   r8   r   r+   )#
__future__r   r:   r"   r&   r   r   typingr   r   r   urllib.parser   urllib.requestr   r	   r1   r<   typing_extensionsr
   r   r   ImportErrorTIMEOUT_SECr   r   r$   r*   r-   r5   r,   r   r   UserWarningrH   r   r   r   r    <module>   s>    


