
    wdf                         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	 	 d dl
Zn# e$ r d dlZY nw xY w G d de          Z G d	 d
e          ZdS )    )absolute_importN   )	text_type)
BadRequest)detect_utf_encodingc                   P    e Zd Zed             Zed             Zed             ZdS )_JSONModulec                 .   t          | t          j                  r|                                 S t          | t          j                  rt          |           S t          | d          r!t          | 	                                          S t                      )N__html__)
isinstancedatetimedate	isoformatuuidUUIDstrhasattrr   r   	TypeError)os    [/var/www/book.euthymeo.com/html/venv/lib/python3.11/site-packages/werkzeug/wrappers/json.py_defaultz_JSONModule._default   su    a'' 	!;;== a## 	q66M1j!! 	+QZZ\\***kk    c                     |                     dd           |                     d| j                   |                     dd           t          j        |fi |S )N
separators),:default	sort_keysT)
setdefaultr   _jsondumps)clsobjkws      r   r!   z_JSONModule.dumps   sX    
lJ///
i...
k4((({3%%"%%%r   c                     t          | t                    r$t          |           }|                     |          } t	          j        | fi |S )N)r   bytesr   decoder    loads)sr$   encodings      r   r(   z_JSONModule.loads%   sJ    a 	#*1--H""A{1#####r   N)__name__
__module____qualname__staticmethodr   classmethodr!   r(    r   r   r	   r	      sc        
 
 \
 & & [& $ $ \$ $ $r   r	   c                   ^    e Zd ZdZeZed             Zed             Zd Z	e
e
fZd
dZd Zd	S )	JSONMixinaD  Mixin to parse :attr:`data` as JSON. Can be mixed in for both
    :class:`~werkzeug.wrappers.Request` and
    :class:`~werkzeug.wrappers.Response` classes.

    If `simplejson`_ is installed it is preferred over Python's built-in
    :mod:`json` module.

    .. _simplejson: https://simplejson.readthedocs.io/en/latest/
    c                 *    |                                  S )zThe parsed JSON data if :attr:`mimetype` indicates JSON
        (:mimetype:`application/json`, see :meth:`is_json`).

        Calls :meth:`get_json` with default arguments.
        )get_json)selfs    r   jsonzJSONMixin.json>   s     }}r   c                 p    | j         }|dk    p)|                    d          o|                    d          S )zCheck if the mimetype indicates JSON data, either
        :mimetype:`application/json` or :mimetype:`application/*+json`.
        zapplication/jsonzapplication/z+json)mimetype
startswithendswith)r5   mts     r   is_jsonzJSONMixin.is_jsonG   sA    
 ]$$ %}}^,, %G$$	
r   c                 x    	 |                      |          S # t          $ r |                                  cY S w xY w)Ncache)get_datar   )r5   r?   s     r   _get_data_for_jsonzJSONMixin._get_data_for_jsonS   sJ    	#==u=--- 	# 	# 	#==??"""	#s    99FTc                    |r!| j         |         t          ur| j         |         S |s	| j        sdS |                     |          }	 | j                            |          }|r	||f| _         n[# t          $ rN}|rd}|r| j         \  }}||f| _         n*|                     |          }|r| j         \  }}	||	f| _         Y d}~nd}~ww xY w|S )a&  Parse :attr:`data` as JSON.

        If the mimetype does not indicate JSON
        (:mimetype:`application/json`, see :meth:`is_json`), this
        returns ``None``.

        If parsing fails, :meth:`on_json_loading_failed` is called and
        its return value is used as the return value.

        :param force: Ignore the mimetype and always try to parse JSON.
        :param silent: Silence parsing errors and return ``None``
            instead.
        :param cache: Store the parsed JSON to return for subsequent
            calls.
        Nr>   )_cached_jsonEllipsisr<   rA   json_moduler(   
ValueErroron_json_loading_failed)
r5   forcesilentr?   datarve	normal_rv_	silent_rvs
             r   r4   zJSONMixin.get_json^   s      	-T&v.h>>$V,, 	 	4&&U&33	-!''--B  -%'H!  	8 	8 	8 8 8#'#4LIq)2BD%0033 8#'#4LAy)+YD%	8" 	s   A, ,
C6AB??Cc                 F    t          d                    |                    )zCalled if :meth:`get_json` parsing fails and isn't silenced.
        If this method returns a value, it is used as the return value
        for :meth:`get_json`. The default implementation raises
        :exc:`~werkzeug.exceptions.BadRequest`.
        z!Failed to decode JSON object: {0})r   format)r5   rL   s     r   rG   z JSONMixin.on_json_loading_failed   s!     <CCAFFGGGr   N)FFT)r+   r,   r-   __doc__r	   rE   propertyr6   r<   rA   rD   rC   r4   rG   r0   r   r   r2   r2   /   s          K  X 	
 	
 X	
# # # h'L+ + + +ZH H H H Hr   r2   )
__future__r   r   r   _compatr   
exceptionsr   utilsr   
simplejsonr    ImportErrorr6   objectr	   r2   r0   r   r   <module>r[      s   & & & & & &         # # # # # # ' ' ' ' ' '   $ $ $ $ $& $ $ $>bH bH bH bH bH bH bH bH bH bHs   ' 	33