
    F d+                       d dl m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ej                  Z G d dej                  Zddd%dZddd&dZddd'dZddd(dZd)d Zd*d!Zd+d$ZdS ),    )annotationsN)htmlsafe_json_dumps   )current_app   _default)Flask)Responsec                  ,     e Zd ZdZd fdZd	dZ xZS )
JSONEncodera>  The default JSON encoder. Handles extra types compared to the
    built-in :class:`json.JSONEncoder`.

    -   :class:`datetime.datetime` and :class:`datetime.date` are
        serialized to :rfc:`822` strings. This is the same as the HTTP
        date format.
    -   :class:`decimal.Decimal` is serialized to a string.
    -   :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.

    Assign a subclass of this to :attr:`flask.Flask.json_encoder` or
    :attr:`flask.Blueprint.json_encoder` to override the default.

    .. deprecated:: 2.2
        Will be removed in Flask 2.3. Use ``app.json`` instead.
    returnNonec                |    dd l }|                    dt          d            t                      j        di | d S )Nr   z'JSONEncoder' is deprecated and will be removed in Flask 2.3. Use 'Flask.json' to provide an alternate JSON implementation instead.   
stacklevel warningswarnDeprecationWarningsuper__init__selfkwargsr   	__class__s      \C:\Users\ChattiNader\Documents\MyHotelMatch\api\dev\Lib\site-packages\flask/json/__init__.pyr   zJSONEncoder.__init__%   Y    ,  	 	
 	
 	
 	""6"""""    ot.Anyc                     t          |          S )zConvert ``o`` to a JSON serializable type. See
        :meth:`json.JSONEncoder.default`. Python does not support
        overriding how basic types like ``str`` or ``list`` are
        serialized, they are handled before this method.
        r   )r   r"   s     r   defaultzJSONEncoder.default1   s     {{r!   r   r   )r"   r#   r   r#   )__name__
__module____qualname____doc__r   r%   __classcell__r   s   @r   r   r      s[         (
# 
# 
# 
# 
# 
#       r!   r   c                  $     e Zd ZdZd fdZ xZS )JSONDecoderaW  The default JSON decoder.

    This does not change any behavior from the built-in
    :class:`json.JSONDecoder`.

    Assign a subclass of this to :attr:`flask.Flask.json_decoder` or
    :attr:`flask.Blueprint.json_decoder` to override the default.

    .. deprecated:: 2.2
        Will be removed in Flask 2.3. Use ``app.json`` instead.
    r   r   c                |    dd l }|                    dt          d            t                      j        di | d S )Nr   z'JSONDecoder' is deprecated and will be removed in Flask 2.3. Use 'Flask.json' to provide an alternate JSON implementation instead.r   r   r   r   r   s      r   r   zJSONDecoder.__init__G   r    r!   r&   )r'   r(   r)   r*   r   r+   r,   s   @r   r.   r.   :   sG        
 

# 
# 
# 
# 
# 
# 
# 
# 
# 
#r!   r.   )appobjr#   r0   Flask | Noner   r   strc                   |"ddl }|                    dt          d           nt          }|r |j        j        | fi |S |                    dt                     t          j        | fi |S )aW  Serialize data as JSON.

    If :data:`~flask.current_app` is available, it will use its
    :meth:`app.json.dumps() <flask.json.provider.JSONProvider.dumps>`
    method, otherwise it will use :func:`json.dumps`.

    :param obj: The data to serialize.
    :param kwargs: Arguments passed to the ``dumps`` implementation.

    .. versionchanged:: 2.2
        Calls ``current_app.json.dumps``, allowing an app to override
        the behavior.

    .. versionchanged:: 2.2
        The ``app`` parameter will be removed in Flask 2.3.

    .. versionchanged:: 2.0.2
        :class:`decimal.Decimal` is supported by converting to a string.

    .. versionchanged:: 2.0
        ``encoding`` will be removed in Flask 2.1.

    .. versionchanged:: 1.0.3
        ``app`` can be passed directly, rather than requiring an app
        context for configuration.
    Nr   zkThe 'app' parameter is deprecated and will be removed in Flask 2.3. Call 'app.json.dumps' directly instead.r   r   r%   )	r   r   r   r   jsondumps
setdefaultr	   _json)r1   r0   r   r   s       r   r6   r6   T   s    6 B	 	 	
 	
 	
 	
 
 -sx~c,,V,,,
i***;s%%f%%%r!   fp	t.IO[str]r   c                   |"ddl }|                    dt          d           nt          }|r |j        j        | |fi | dS |                    dt                     t          j        | |fi | dS )a  Serialize data as JSON and write to a file.

    If :data:`~flask.current_app` is available, it will use its
    :meth:`app.json.dump() <flask.json.provider.JSONProvider.dump>`
    method, otherwise it will use :func:`json.dump`.

    :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: Arguments passed to the ``dump`` implementation.

    .. versionchanged:: 2.2
        Calls ``current_app.json.dump``, allowing an app to override
        the behavior.

    .. versionchanged:: 2.2
        The ``app`` parameter will be removed in Flask 2.3.

    .. versionchanged:: 2.0
        Writing to a binary file, and the ``encoding`` argument, will be
        removed in Flask 2.1.
    Nr   zjThe 'app' parameter is deprecated and will be removed in Flask 2.3. Call 'app.json.dump' directly instead.r   r   r%   )	r   r   r   r   r5   dumpr7   r	   r8   )r1   r9   r0   r   r   s        r   r<   r<      s    2 A	 	 	
 	
 	
 	
 
 &c2((((((()X...
3%%f%%%%%r!   sstr | bytesc                   |"ddl }|                    dt          d           nt          }|r |j        j        | fi |S t          j        | fi |S )a  Deserialize data as JSON.

    If :data:`~flask.current_app` is available, it will use its
    :meth:`app.json.loads() <flask.json.provider.JSONProvider.loads>`
    method, otherwise it will use :func:`json.loads`.

    :param s: Text or UTF-8 bytes.
    :param kwargs: Arguments passed to the ``loads`` implementation.

    .. versionchanged:: 2.2
        Calls ``current_app.json.loads``, allowing an app to override
        the behavior.

    .. versionchanged:: 2.2
        The ``app`` parameter will be removed in Flask 2.3.

    .. versionchanged:: 2.0
        ``encoding`` will be removed in Flask 2.1. The data must be a
        string or UTF-8 bytes.

    .. versionchanged:: 1.0.3
        ``app`` can be passed directly, rather than requiring an app
        context for configuration.
    Nr   zkThe 'app' parameter is deprecated and will be removed in Flask 2.3. Call 'app.json.loads' directly instead.r   r   )r   r   r   r   r5   loadsr8   )r=   r0   r   r   s       r   r@   r@      s    2 B	 	 	
 	
 	
 	
 
 +sx~a**6***;q##F###r!   t.IO[t.AnyStr]c                   |"ddl }|                    dt          d           nt          }|r |j        j        | fi |S t          j        | fi |S )a  Deserialize data as JSON read from a file.

    If :data:`~flask.current_app` is available, it will use its
    :meth:`app.json.load() <flask.json.provider.JSONProvider.load>`
    method, otherwise it will use :func:`json.load`.

    :param fp: A file opened for reading text or UTF-8 bytes.
    :param kwargs: Arguments passed to the ``load`` implementation.

    .. versionchanged:: 2.2
        Calls ``current_app.json.load``, allowing an app to override
        the behavior.

    .. versionchanged:: 2.2
        The ``app`` parameter will be removed in Flask 2.3.

    .. versionchanged:: 2.0
        ``encoding`` will be removed in Flask 2.1. The file must be text
        mode, or binary mode with UTF-8 bytes.
    Nr   zjThe 'app' parameter is deprecated and will be removed in Flask 2.3. Call 'app.json.load' directly instead.r   r   )r   r   r   r   r5   loadr8   )r9   r0   r   r   s       r   rC   rC      s    * A	 	 	
 	
 	
 	
 
 +sx}R**6***:b##F###r!   c                l    ddl }|                    dt          d           t          | fdt          i|S )a  Serialize an object to a string of JSON with :func:`dumps`, then
    replace HTML-unsafe characters with Unicode escapes and mark the
    result safe with :class:`~markupsafe.Markup`.

    This is available in templates as the ``|tojson`` filter.

    The returned string is safe to render in HTML documents and
    ``<script>`` tags. The exception is in HTML attributes that are
    double quoted; either use single quotes or the ``|forceescape``
    filter.

    .. deprecated:: 2.2
        Will be removed in Flask 2.3. This is built-in to Jinja now.

    .. versionchanged:: 2.0
        Uses :func:`jinja2.utils.htmlsafe_json_dumps`. The returned
        value is marked safe by wrapping in :class:`~markupsafe.Markup`.

    .. versionchanged:: 0.10
        Single quotes are escaped, making this safe to use in HTML,
        ``<script>`` tags, and single-quoted attributes without further
        escaping.
    r   Nzp'htmlsafe_dumps' is deprecated and will be removed in Flask 2.3. Use 'jinja2.utils.htmlsafe_json_dumps' instead.r   r   r6   )r   r   r   _jinja_htmlsafe_dumpsr6   )r1   r   r   s      r   htmlsafe_dumpsrF      sQ    0 OOOMM	@	     !<<E<V<<<r!   c                    ddl }|                    dt          d           |                    t	          | fi |           dS )zSerialize an object to JSON written to a file object, replacing
    HTML-unsafe characters with Unicode escapes. See
    :func:`htmlsafe_dumps` and :func:`dumps`.

    .. deprecated:: 2.2
        Will be removed in Flask 2.3.
    r   Nzo'htmlsafe_dump' is deprecated and will be removed in Flask 2.3. Use 'jinja2.utils.htmlsafe_json_dumps' instead.r   r   )r   r   r   writerF   )r1   r9   r   r   s       r   htmlsafe_dumprI   #  s^     OOOMM	@	     HH^C**6**+++++r!   argsr   c                 .    t          j        j        | i |S )a  Serialize the given arguments as JSON, and return a
    :class:`~flask.Response` object with the ``application/json``
    mimetype. A dict or list returned from a view will be converted to a
    JSON response automatically without needing to call this.

    This requires an active request or application context, and calls
    :meth:`app.json.response() <flask.json.provider.JSONProvider.response>`.

    In debug mode, the output is formatted with indentation to make it
    easier to read. This may also be controlled by the provider.

    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.

    .. versionchanged:: 2.2
        Calls ``current_app.json.response``, allowing an app to override
        the behavior.

    .. versionchanged:: 2.0.2
        :class:`decimal.Decimal` is supported by converting to a string.

    .. versionchanged:: 0.11
        Added support for serializing top-level arrays. This was a
        security risk in ancient browsers. See :ref:`security-json`.

    .. versionadded:: 0.2
    )r   r5   response)rJ   r   s     r   jsonifyrM   6  s    @ $d5f555r!   )r1   r#   r0   r2   r   r#   r   r3   )
r1   r#   r9   r:   r0   r2   r   r#   r   r   )r=   r>   r0   r2   r   r#   r   r#   )r9   rA   r0   r2   r   r#   r   r#   )r1   r#   r   r#   r   r3   )r1   r#   r9   r:   r   r#   r   r   )rJ   r#   r   r#   r   r   )
__future__r   r5   r8   typingtjinja2.utilsr   rE   globalsr   providerr	   TYPE_CHECKINGr0   r
   wrappersr   r   r.   r6   r<   r@   rC   rF   rI   rM   r   r!   r   <module>rV      s   " " " " " "         E E E E E E ! ! ! ! ! !      ? $######' ' ' ' '%# ' ' 'T# # # # #%# # # #4 .2 +& +& +& +& +& +&^ 7;)& )& )& )& )& )&X 26 ($ ($ ($ ($ ($ ($V 59 $$ $$ $$ $$ $$ $$N =  =  =  =F, , , ,& 6  6  6  6  6  6r!   