
    F d)                        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d dlZd dl	m
Z
 d dlmZ ddlmZ ej        rddlmZ ddlmZ  G d	 d
          ZddZ G d de          ZdS )    )annotationsN)date)	http_date   )request)Flask)Responsec                  J    e Zd ZdZddZddZddZddZddZd dZ	d!dZ
dS )"JSONProvidera  A standard set of JSON operations for an application. Subclasses
    of this can be used to customize JSON behavior or use different
    JSON libraries.

    To implement a provider for a specific library, subclass this base
    class and implement at least :meth:`dumps` and :meth:`loads`. All
    other methods have default implementations.

    To use a different provider, either subclass ``Flask`` and set
    :attr:`~flask.Flask.json_provider_class` to a provider class, or set
    :attr:`app.json <flask.Flask.json>` to an instance of the class.

    :param app: An application instance. This will be stored as a
        :class:`weakref.proxy` on the :attr:`_app` attribute.

    .. versionadded:: 2.2
    appr   returnNonec                8    t          j        |          | _        d S )N)weakrefproxy_app)selfr   s     \C:\Users\ChattiNader\Documents\MyHotelMatch\api\dev\Lib\site-packages\flask/json/provider.py__init__zJSONProvider.__init__'   s    M#&&			    objt.Anykwargsstrc                    t           )zSerialize data as JSON.

        :param obj: The data to serialize.
        :param kwargs: May be passed to the underlying JSON library.
        NotImplementedError)r   r   r   s      r   dumpszJSONProvider.dumps*   
     "!r   fp	t.IO[str]c                H    |                      | j        |fi |           dS )a  Serialize data as JSON and write to a file.

        :param obj: The data to serialize.
        :param fp: A file opened for writing text. Should use the UTF-8
            encoding to be valid JSON.
        :param kwargs: May be passed to the underlying JSON library.
        N)writer   )r   r   r    r   s       r   dumpzJSONProvider.dump2   s0     	C**6**+++++r   sstr | bytesc                    t           )zDeserialize data as JSON.

        :param s: Text or UTF-8 bytes.
        :param kwargs: May be passed to the underlying JSON library.
        r   )r   r%   r   s      r   loadszJSONProvider.loads<   r   r   t.IO[t.AnyStr]c                B     | j         |                                fi |S )zDeserialize data as JSON read from a file.

        :param fp: A file opened for reading text or UTF-8 bytes.
        :param kwargs: May be passed to the underlying JSON library.
        )r(   read)r   r    r   s      r   loadzJSONProvider.loadD   s&     tz"''))..v...r   argst.Tuple[t.Any, ...]t.Dict[str, t.Any]c                r    |r|rt          d          |s|sd S t          |          dk    r|d         S |p|S )Nz9app.json.response() takes either args or kwargs, not both   r   )	TypeErrorlen)r   r-   r   s      r   _prepare_response_objz"JSONProvider._prepare_response_objL   sZ      	YF 	YWXXX 	F 	4t99>>7N~vr   r	   c                    |                      ||          }| j                            |                     |          d          S )a(  Serialize the given arguments as JSON, and return a
        :class:`~flask.Response` object with the ``application/json``
        mimetype.

        The :func:`~flask.json.jsonify` function calls this method for
        the current application.

        Either positional or keyword arguments can be given, not both.
        If no arguments are given, ``None`` is serialized.

        :param args: A single value to serialize, or multiple values to
            treat as a list to serialize.
        :param kwargs: Treat as a dict to serialize.
        application/jsonmimetype)r4   r   response_classr   )r   r-   r   r   s       r   responsezJSONProvider.responseZ   s?     ((v66y''

3BT'UUUr   N)r   r   r   r   r   r   r   r   r   r   )r   r   r    r!   r   r   r   r   r%   r&   r   r   r   r   )r    r)   r   r   r   r   )r-   r.   r   r/   r   r   r-   r   r   r   r   r	   )__name__
__module____qualname____doc__r   r   r$   r(   r,   r4   r:    r   r   r   r      s         $' ' ' '" " " ", , , ," " " "/ / / /   V V V V V Vr   r   or   r   c                   t          | t                    rt          |           S t          | t          j        t
          j        f          rt          |           S t          r(t          j	        |           rt          j
        |           S t          | d          r!t          |                                           S t          dt          |           j         d          )N__html__zObject of type z is not JSON serializable)
isinstancer   r   decimalDecimaluuidUUIDr   dataclassesis_dataclassasdicthasattrrE   r2   typer>   )rC   s    r   _defaultrP   m   s    !T ||!goty122 1vv %{/22 %!!$$$q* !1::<<   
Qd1gg&6QQQ
R
RRr   c                  p    e Zd ZU dZ ee          Zded<   	 dZ	 dZ		 dZ
ded<   	 dZ	 ddZddZddZdS )DefaultJSONProvidera4  Provide JSON operations using Python's built-in :mod:`json`
    library. Serializes the following additional data types:

    -   :class:`datetime.datetime` and :class:`datetime.date` are
        serialized to :rfc:`822` strings. This is the same as the HTTP
        date format.
    -   :class:`uuid.UUID` is serialized to a string.
    -   :class:`dataclasses.dataclass` is passed to
        :func:`dataclasses.asdict`.
    -   :class:`~markupsafe.Markup` (or any object with a ``__html__``
        method) will call the ``__html__`` method to get a string.
    zt.Callable[[t.Any], t.Any]defaultTNzbool | Nonecompactr6   r   r   r   r   r   c                   | j         j        }t          r)| j         j                            t          j                  nd}||j        |j        }|Zddl}|                    dt                     |	                    d|           d|j
        vr|	                    d| j                   n|	                    d| j                   | j         j        d         }| j         j        d         }| ddl}|                    dt                     n| j        }| ddl}|                    d	t                     n| j        }|	                    d
|           |	                    d|           t          j        |fi |S )aI  Serialize data as JSON to a string.

        Keyword arguments are passed to :func:`json.dumps`. Sets some
        parameter defaults from the :attr:`default`,
        :attr:`ensure_ascii`, and :attr:`sort_keys` attributes.

        :param obj: The data to serialize.
        :param kwargs: Passed to :func:`json.dumps`.
        Nr   z~Setting 'json_encoder' on the app or a blueprint is deprecated and will be removed in Flask 2.3. Customize 'app.json' instead.clsrS   JSON_AS_ASCIIJSON_SORT_KEYSzsThe 'JSON_AS_ASCII' config key is deprecated and will be removed in Flask 2.3. Set 'app.json.ensure_ascii' instead.zqThe 'JSON_SORT_KEYS' config key is deprecated and will be removed in Flask 2.3. Set 'app.json.sort_keys' instead.ensure_ascii	sort_keys)r   _json_encoderr   
blueprintsget	blueprintwarningswarnDeprecationWarning
setdefault__dict__rS   configrY   rZ   jsonr   )r   r   r   rV   bpr_   rY   rZ   s           r   r   zDefaultJSONProvider.dumps   s    i%<CMTY!%%g&7888>b.:"C?OOOMM1 #	   eS))),,!!)T\:::i666y'8I$%56	#OOOMM #	     ,L OOOMM #	    I.,777+y111z#(((((r   r%   r&   c                0   | j         j        }t          r)| j         j                            t          j                  nd}||j        |j        }|5ddl}|                    dt                     |	                    d|           t          j        |fi |S )zDeserialize data as JSON from a string or bytes.

        :param s: Text or UTF-8 bytes.
        :param kwargs: Passed to :func:`json.loads`.
        Nr   z~Setting 'json_decoder' on the app or a blueprint is deprecated and will be removed in Flask 2.3. Customize 'app.json' instead.rV   )r   _json_decoderr   r\   r]   r^   r_   r`   ra   rb   re   r(   )r   r%   r   rV   rf   r_   s         r   r(   zDefaultJSONProvider.loads   s     i%<CMTY!%%g&7888>b.:"C?OOOMM1 #	   eS)))z!&&v&&&r   r-   r	   c                   |                      ||          }i }| j        j        d         }| j        j        d         }|#ddl}|                    dt
                     | }n| j        }|| j        j        s|du r|                    dd           n|                    d	d
           | ddl}|                    dt
                     n| j	        }| j        
                     | j        |fi | d|          S )a  Serialize the given arguments as JSON, and return a
        :class:`~flask.Response` object with it. The response mimetype
        will be "application/json" and can be changed with
        :attr:`mimetype`.

        If :attr:`compact` is ``False`` or debug mode is enabled, the
        output will be formatted to be easier to read.

        Either positional or keyword arguments can be given, not both.
        If no arguments are given, ``None`` is serialized.

        :param args: A single value to serialize, or multiple values to
            treat as a list to serialize.
        :param kwargs: Treat as a dict to serialize.
        JSONIFY_PRETTYPRINT_REGULARJSONIFY_MIMETYPENr   z|The 'JSONIFY_PRETTYPRINT_REGULAR' config key is deprecated and will be removed in Flask 2.3. Set 'app.json.compact' instead.Findentr   
separators),:zrThe 'JSONIFY_MIMETYPE' config key is deprecated and will be removed in Flask 2.3. Set 'app.json.mimetype' instead.
r7   )r4   r   rd   r_   r`   ra   rT   debugrb   r8   r9   r   )	r   r-   r   r   	dump_argsprettyr8   r_   rT   s	            r   r:   zDefaultJSONProvider.response  sC     ((v66(*	!"?@9#$67OOOMM/ #	   (.:GGlGO	OGu4D4D  1----  z:::OOOMM #	    }Hy''tz#++++///( ( 
 
 	
r   r;   r<   r=   )r>   r?   r@   rA   staticmethodrP   rS   __annotations__rY   rZ   rT   r8   r   r(   r:   rB   r   r   rR   rR   }   s           +7,+ +G    
 L
 I  G
 "H/=) =) =) =)~' ' ' '25
 5
 5
 5
 5
 5
r   rR   )rC   r   r   r   )
__future__r   rK   rG   re   typingtrI   r   datetimer   werkzeug.httpr   globalsr   TYPE_CHECKINGr   r   wrappersr	   r   rP   rR   rB   r   r   <module>r~      sF   " " " " " "                   # # # # # #      ? $######VV VV VV VV VV VV VV VVrS S S S y
 y
 y
 y
 y
, y
 y
 y
 y
 y
r   