
    g                        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 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y)    )annotationsN)date)	http_date)Response   )Appc                  T    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
y	)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
    c                8    t        j                  |      | _        y )N)weakrefproxy_app)selfapps     p/var/www/html/FastMealFinder_FlaskServer-InitialRelease/venv/lib/python3.12/site-packages/flask/json/provider.py__init__zJSONProvider.__init__&   s     s+	    c                    t         )zSerialize data as JSON.

        :param obj: The data to serialize.
        :param kwargs: May be passed to the underlying JSON library.
        NotImplementedErrorr   objkwargss      r   dumpszJSONProvider.dumps)   
     "!r   c                H    |j                   | j                  |fi |       y)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   fpr   s       r   dumpzJSONProvider.dump1   s      	C*6*+r   c                    t         )zDeserialize data as JSON.

        :param s: Text or UTF-8 bytes.
        :param kwargs: May be passed to the underlying JSON library.
        r   r   sr   s      r   loadszJSONProvider.loads;   r   r   c                D     | j                   |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.loadC   s      tzz"'').v..r   c                \    |r|rt        d      |s|sy t        |      dk(  r|d   S |xs |S )Nz9app.json.response() takes either args or kwargs, not both   r   )	TypeErrorlen)r   argsr   s      r   _prepare_response_objz"JSONProvider._prepare_response_objK   s;     FWXXFt9>7N~vr   c                ~    | j                  ||      }| j                  j                  | 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)r,   r   response_classr   )r   r+   r   r   s       r   responsezJSONProvider.responseY   s9     ((v6yy''

3BT'UUr   N)r   r   returnNoner   t.Anyr   r6   r3   str)r   r6   r   z	t.IO[str]r   r6   r3   r4   r"   zstr | bytesr   r6   r3   r6   )r   zt.IO[t.AnyStr]r   r6   r3   r6   )r+   ztuple[t.Any, ...]r   zdict[str, t.Any]r3   r6   r+   r6   r   r6   r3   r   )__name__
__module____qualname____doc__r   r   r   r#   r&   r,   r2    r   r   r
   r
      sC    $,","/%/?	Vr   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        | j                               S t        dt        |       j                   d      )N__html__zObject of type z is not JSON serializable)
isinstancer   r   decimalDecimaluuidUUIDr7   dataclassesis_dataclassasdicthasattrr@   r)   typer:   )os    r   _defaultrL   l   s    !T|!gootyy121v{//2!!!$$q*1::<  
od1g&6&6%77PQ
RRr   c                  h    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y)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compactr.   c                    |j                  d| j                         |j                  d| j                         |j                  d| j                         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`.
        rO   ensure_ascii	sort_keys)
setdefaultrO   rR   rS   jsonr   r   s      r   r   zDefaultJSONProvider.dumps   sV     	)T\\2.$*;*;<+t~~6zz#(((r   c                .    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`.
        )rU   r#   r!   s      r   r#   zDefaultJSONProvider.loads   s     zz!&v&&r   c                J   | j                  ||      }i }| j                  | j                  j                  s| j                  du r|j	                  dd       n|j	                  dd       | j                  j                   | j                  |fi | d| j                        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.
        Findentr   
separators),:
r/   )r,   rP   r   debugrT   r1   r   r0   )r   r+   r   r   	dump_argss        r   r2   zDefaultJSONProvider.response   s      ((v6&(	LL TYY__9N  1-  z:yy''tzz#++,B/$-- ( 
 	
r   r5   r8   r9   )r:   r;   r<   r=   staticmethodrL   rO   __annotations__rR   rS   rP   r0   r   r#   r2   r>   r   r   rN   rN   |   s`     +7x*@G'@
 L
 I  G[
 "H/)'
r   rN   )rK   r6   r3   r6   )
__future__r   rF   rB   rU   typingtrD   r   datetimer   werkzeug.httpr   TYPE_CHECKINGwerkzeug.sansio.responser   
sansio.appr   r
   rL   rN   r>   r   r   <module>ri      sP    "        #??1 VV VVrS [
, [
r   