
    E6i,                        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  e j                  d      Z
 e j                  d      ZdZd	 Z e       Z G d
 de      Zd Zd Zd Zd Zd Zej,                  fdZdej0                  defdZd Zy)    N)OrderedDict)deepcopy   )
HTTPStatusz(.)([A-Z][a-z]+)z([a-z0-9])([A-Z]))mergecamel_to_dash
default_idnot_nonenot_none_sortedunpackBaseResponseimport_check_view_funcc                      ddl } t        | j                  j                  d      j	                  d      d         }|dk  rddlm} |S ddlm} |S )znResolve `werkzeug` `Response` class import because
    `BaseResponse` was renamed in version 2.* to `Response`r   Nwerkzeug.   )r   )Response)importlib.metadataintmetadataversionsplitwerkzeug.wrappersr   r   )	importlibwerkzeug_majorr   r   s       T/home/azureuser/techstart-app/venv/lib/python3.12/site-packages/flask_restx/utils.pyimport_werkzeug_responser      sK     ++33J?EEcJ1MNN2*O    c                       e Zd Zy)FlaskCompatibilityWarningN)__name__
__module____qualname__ r   r   r    r    .   s    r   r    c                     t        |t              s|S t        |       }|j                         D ]=  \  }}||v r&t        ||   t              rt	        ||   |      ||<   0t        |      ||<   ? |S )aA  
    Recursively merges two dictionaries.

    Second dictionary values will take precedence over those from the first one.
    Nested dictionaries are merged too.

    :param dict first: The first dictionary
    :param dict second: The second dictionary
    :return: the resulting merged dictionary
    :rtype: dict
    )
isinstancedictr   itemsr   )firstsecondresultkeyvalues        r   r   r   2   sq     fd#e_Flln *
U&=ZsT:sU3F3K"5/F3K	*
 Mr   c                 v    t         j                  d|       }t        j                  d|      j                         S )z
    Transform a CamelCase string into a low_dashed one

    :param str value: a CamelCase string to transform
    :return: the low_dashed string
    :rtype: str
    z\1_\2)FIRST_CAP_REsub
ALL_CAP_RElower)r-   	first_caps     r   r   r   I   s0       51I>>(I.4466r   c                 8    dj                  |t        |             S )zDefault operation ID generatorz{0}_{1})formatr   )resourcemethods     r   r	   r	   U   s    FM($;<<r   c                 B    t        d | j                         D              S )z
    Remove all keys where value is None

    :param dict data: A dictionary with potentially some values set to None
    :return: The same dictionary without the keys with values to ``None``
    :rtype: dict
    c              3   0   K   | ]  \  }}|	||f  y wNr$   .0kvs      r   	<genexpr>znot_none.<locals>.<genexpr>b   s     A41a1=AA   
	)r'   r(   datas    r   r
   r
   Z   s     A4::<AAAr   c                 T    t        d t        | j                               D              S )z
    Remove all keys where value is None

    :param OrderedDict data: A dictionary with potentially some values set to None
    :return: The same dictionary without the keys with values to ``None``
    :rtype: OrderedDict
    c              3   0   K   | ]  \  }}|	||f  y wr:   r$   r;   s      r   r?   z"not_none_sorted.<locals>.<genexpr>m   s     P$!Q!-1vPr@   )r   sortedr(   rA   s    r   r   r   e   s      P&*>PPPr   c                     t        | t              s| |i fS t        |       dk(  r| d   |i fS t        |       dk(  r
| \  }}||i fS t        |       dk(  r| \  }}}||xs ||fS t        d      )ao  
    Unpack a Flask standard response.

    Flask response can be:
    - a single value
    - a 2-tuple ``(value, code)``
    - a 3-tuple ``(value, code, headers)``

    .. warning::

        When using this function, you must ensure that the tuple is not the response data.
        To do so, prefer returning list instead of tuple for listings.

    :param response: A Flask style response
    :param int default_code: The HTTP code to use as default if none is provided
    :return: a 3-tuple ``(data, code, headers)``
    :rtype: tuple
    :raise ValueError: if the response does not have one of the expected format
    r   r   r      zToo many response values)r&   tuplelen
ValueError)responsedefault_coderB   codeheaderss        r   r   r   p   s    ( h&r))	X!	{L",,	X!	
dT2~	X!	&dGT)\722344r   	view_funcreturnc                 ,    | J d       | j                   S )zHelper that returns the default endpoint for a given
    function. This always is the function name.

    Note: copy of simple flask internal helper
    z/expected view func if endpoint is not provided.)r!   )rO   s    r   to_view_namerR      s"      S"SS r   c                  \   ddl } | j                  j                  d      j                  d      }	 |d   dk(  rddlm} n:|d   dk(  rddlm} n+|d   dk(  rddlm} nt        j                  d	t               d}|t        }|S # t        $ r t        j                  d	t               d}Y 1w xY w)
a0  
    Resolve import flask _endpoint_from_view_func.

    Show warning if function cannot be found and provide copy of last known implementation.

    Note: This helper method exists because reoccurring problem with flask function, but
    actual method body remaining the same in each flask version.
    r   Nflaskr   1)_endpoint_from_view_func23once)r   r   r   r   flask.helpersrV   flask.scaffoldflask.sansio.scaffoldwarningssimplefilterr    ImportErrorrR   )r   flask_versionrV   s      r   r   r      s     &&..w7==cBM(s">1$?1$F!!&*CD'+$  '#/ ##  (f&?@#' (s   A	B %B+*B+)rer]   typingcollectionsr   copyr   _httpr   compiler/   r1   __all__r   r   DeprecationWarningr    r   r   r	   r
   r   OKr   CallablestrrR   r   r$   r   r   <module>rl      s    	   #   rzz,-RZZ+,
	  ()	 2 	.	7=
BQ #--- #5LFOO  $r   