https://t.me/AnonymousX5
Server : Apache
System : Linux cvar2.toservers.com 3.10.0-962.3.2.lve1.5.73.el7.x86_64 #1 SMP Wed Aug 24 21:31:23 UTC 2022 x86_64
User : njnconst ( 1116)
PHP Version : 8.4.18
Disable Function : NONE
Directory :  /usr/lib64/python2.7/site-packages/flask/json/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/lib64/python2.7/site-packages/flask/json/__init__.pyc
�
-/�_c	@s�dZddlZddlZddlZddlmZddlmZddlmZddl	m
Z
ddlmZdd	l
mZdd
l
mZddlmZddlmZyddlZWnek
r�dZnXd
ejd�kZdddddddddg	Zd�Zd�Zdejfd��YZdejfd��YZdd�Zdd�Zd�Zdd�Zdd �Z dd!�Z!dd"�Z"d#�Z#d$�Z$d%�Z%d&�Z&dS('sH
flask.json
~~~~~~~~~~

:copyright: 2010 Pallets
:license: BSD-3-Clause
i����N(tdate(tdatetime(tjson(tMarkup(t	http_datei(tPY2(t	text_type(tcurrent_app(trequests\/t/tdumptdumpstloadtloadst
htmlsafe_dumpthtmlsafe_dumpstJSONDecodertJSONEncodertjsonifycCs:t|jd�t�r6tjtj|�|�}n|S(Ni(t
isinstancetreadtbytestiot
TextIOWrappertBufferedReader(tfptencoding((s4/tmp/pip-install-sTXtzD/flask/flask/json/__init__.pyt_wrap_reader_for_text/scCs;y|jd�Wn#tk
r6tj||�}nX|S(Nt(twritet	TypeErrorRR(RR((s4/tmp/pip-install-sTXtzD/flask/flask/json/__init__.pyt_wrap_writer_for_text5s

cBseZdZd�ZRS(slThe default Flask JSON encoder. This one extends the default
    encoder by also supporting ``datetime``, ``UUID``, ``dataclasses``,
    and ``Markup`` objects.

    ``datetime`` objects are serialized as RFC 822 datetime strings.
    This is the same as the HTTP date format.

    In order to support more data types, override the :meth:`default`
    method.
    cCs�t|t�rt|j��St|t�r>t|j��St|tj�rZt|�St	r|t	j
|�r|t	j|�St|d�r�t
|j��Stjj||�S(s&Implement this method in a subclass such that it returns a
        serializable object for ``o``, or calls the base implementation (to
        raise a :exc:`TypeError`).

        For example, to support arbitrary iterators, you could implement
        default like this::

            def default(self, o):
                try:
                    iterable = iter(o)
                except TypeError:
                    pass
                else:
                    return list(iterable)
                return JSONEncoder.default(self, o)
        t__html__(RRRtutctimetupleRt	timetupletuuidtUUIDtstrtdataclassestis_dataclasstasdictthasattrRR t_jsonRtdefault(tselfto((s4/tmp/pip-install-sTXtzD/flask/flask/json/__init__.pyR+Is

(t__name__t
__module__t__doc__R+(((s4/tmp/pip-install-sTXtzD/flask/flask/json/__init__.pyR=s
cBseZdZRS(sThe default JSON decoder.  This one does not change the behavior from
    the default simplejson decoder.  Consult the :mod:`json` documentation
    for more information.  This decoder is not only used for the load
    functions of this module but also :attr:`~flask.Request`.
    (R.R/R0(((s4/tmp/pip-install-sTXtzD/flask/flask/json/__init__.pyRgscCs�|dkrt}n|r�tr6|jjtj�nd}|jd|r]|jr]|jn|j�|jds�|jdt	�n|jd|jd�n |jdt
�|jdt�dS(s,Inject default arguments for dump functions.tclst
JSON_AS_ASCIItensure_asciit	sort_keystJSON_SORT_KEYSN(tNoneRRt
blueprintstgett	blueprintt
setdefaulttjson_encodertconfigtFalsetTrueR(tkwargstapptbp((s4/tmp/pip-install-sTXtzD/flask/flask/json/__init__.pyt_dump_arg_defaultsos	!%
cCs~|dkrt}n|rjtr6|jjtj�nd}|jd|r]|jr]|jn|j�n|jdt�dS(s,Inject default arguments for load functions.R1N(	R6RRR7R8R9R:tjson_decoderR(R?R@RA((s4/tmp/pip-install-sTXtzD/flask/flask/json/__init__.pyt_load_arg_defaults�s	!(cCs|d }|d tjkr!dSd|kr1dS|tjtjfkrMdS|d tjtjfkrmdSt|�dkr�|d d	kr�d
S|ddd�dkr�d
S|dd	kr�dS|ddd�dkr�dSnt|�dkr
|jd�r	d
SdSdS(scDetect which UTF codec was used to encode the given bytes.

    The latest JSON standard (:rfc:`8259`) suggests that only UTF-8 is
    accepted. Older documents allowed 8, 16, or 32. 16 and 32 can be big
    or little endian. Some editors or libraries may prepend a BOM.

    :param data: Bytes in unknown UTF encoding.
    :return: UTF encoding name
    iis	utf-8-sigtsutf-8sutf-32isutf-16ts	utf-32-beNts	utf-16-beis	utf-32-les	utf-16-le(tcodecstBOM_UTF8tBOM_UTF32_BEtBOM_UTF32_LEtBOM_UTF16_BEtBOM_UTF16_LEtlent
startswith(tdatathead((s4/tmp/pip-install-sTXtzD/flask/flask/json/__init__.pytdetect_encoding�s*

cKset|d|�|jdd�}tj||�}|dk	rat|t�ra|j|�}n|S(sOSerialize ``obj`` to a JSON-formatted string. If there is an
    app context pushed, use the current app's configured encoder
    (:attr:`~flask.Flask.json_encoder`), or fall back to the default
    :class:`JSONEncoder`.

    Takes the same arguments as the built-in :func:`json.dumps`, and
    does some extra configuration based on the application. If the
    simplejson package is installed, it is preferred.

    :param obj: Object to serialize to JSON.
    :param app: App instance to use to configure the JSON encoder.
        Uses ``current_app`` if not given, and falls back to the default
        encoder when not in an app context.
    :param kwargs: Extra arguments passed to :func:`json.dumps`.

    .. versionchanged:: 1.0.3

        ``app`` can be passed directly, rather than requiring an app
        context for configuration.
    R@RN(RBtpopR6R*RRRtencode(tobjR@R?Rtrv((s4/tmp/pip-install-sTXtzD/flask/flask/json/__init__.pyR�scKsWt|d|�|jdd�}|dk	r@t||�}ntj|||�dS(s1Like :func:`dumps` but writes into a file object.R@RN(RBRSR6RR*R
(RURR@R?R((s4/tmp/pip-install-sTXtzD/flask/flask/json/__init__.pyR
�s
cKsnt|d|�t|t�r^|jdd�}|dkrLt|�}n|j|�}ntj||�S(sXDeserialize an object from a JSON-formatted string ``s``. If
    there is an app context pushed, use the current app's configured
    decoder (:attr:`~flask.Flask.json_decoder`), or fall back to the
    default :class:`JSONDecoder`.

    Takes the same arguments as the built-in :func:`json.loads`, and
    does some extra configuration based on the application. If the
    simplejson package is installed, it is preferred.

    :param s: JSON string to deserialize.
    :param app: App instance to use to configure the JSON decoder.
        Uses ``current_app`` if not given, and falls back to the default
        encoder when not in an app context.
    :param kwargs: Extra arguments passed to :func:`json.dumps`.

    .. versionchanged:: 1.0.3

        ``app`` can be passed directly, rather than requiring an app
        context for configuration.
    R@RN(	RDRRRSR6RRtdecodeR*R
(tsR@R?R((s4/tmp/pip-install-sTXtzD/flask/flask/json/__init__.pyR
�scKsJt|d|�ts:t||jdd�p1d�}ntj||�S(s0Like :func:`loads` but reads from a file object.R@Rsutf-8N(RDRRRSR6R*R(RR@R?((s4/tmp/pip-install-sTXtzD/flask/flask/json/__init__.pyRs$cKs^t||�jdd�jdd�jdd�jdd�}tsZ|jd	d
�}n|S(s:Works exactly like :func:`dumps` but is safe for use in ``<script>``
    tags.  It accepts the same arguments and returns a JSON string.  Note that
    this is available in templates through the ``|tojson`` filter which will
    also mark the result as safe.  Due to how this function escapes certain
    characters this is safe even if used outside of ``<script>`` tags.

    The following characters are escaped in strings:

    -   ``<``
    -   ``>``
    -   ``&``
    -   ``'``

    This makes it safe to embed such strings in any place in HTML with the
    notable exception of double quoted attributes.  In that case single
    quote your attributes or HTML escape it in addition.

    .. versionchanged:: 0.10
       This function's return value is now always safe for HTML usage, even
       if outside of script tags or if used in XHTML.  This rule does not
       hold true when using this function in HTML attributes that are double
       quoted.  Always single quote attributes if you use the ``|tojson``
       filter.  Alternatively use ``|tojson|forceescape``.
    u<u\u003cu>u\u003eu&u\u0026u'u\u0027s\/R	(Rtreplacet
_slash_escape(RUR?RV((s4/tmp/pip-install-sTXtzD/flask/flask/json/__init__.pyRscKs |jtt||���dS(s:Like :func:`htmlsafe_dumps` but writes into a file object.N(RRR(RURR?((s4/tmp/pip-install-sTXtzD/flask/flask/json/__init__.pyR-sc
Os�d}d}tjds"tjr1d}d}n|rL|rLtd��n+t|�dkrk|d	}n|pt|}tjt|d
|d|�dd
tjd�S(sThis function wraps :func:`dumps` to add a few enhancements that make
    life easier.  It turns the JSON output into a :class:`~flask.Response`
    object with the :mimetype:`application/json` mimetype.  For convenience, it
    also converts multiple arguments into an array or multiple keyword arguments
    into a dict.  This means that both ``jsonify(1,2,3)`` and
    ``jsonify([1,2,3])`` serialize to ``[1,2,3]``.

    For clarity, the JSON serialization behavior has the following differences
    from :func:`dumps`:

    1. Single argument: Passed straight through to :func:`dumps`.
    2. Multiple arguments: Converted to an array before being passed to
       :func:`dumps`.
    3. Multiple keyword arguments: Converted to a dict before being passed to
       :func:`dumps`.
    4. Both args and kwargs: Behavior undefined and will throw an exception.

    Example usage::

        from flask import jsonify

        @app.route('/_get_current_user')
        def get_current_user():
            return jsonify(username=g.user.username,
                           email=g.user.email,
                           id=g.user.id)

    This will send a JSON response like this to the browser::

        {
            "username": "admin",
            "email": "admin@localhost",
            "id": 42
        }


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

    This function's response will be pretty printed if the
    ``JSONIFY_PRETTYPRINT_REGULAR`` config parameter is set to True or the
    Flask app is running in debug mode. Compressed (not pretty) formatting
    currently means no indents and no spaces after separators.

    .. versionadded:: 0.2
    t,t:tJSONIFY_PRETTYPRINT_REGULARis, s: s=jsonify() behavior undefined when passed both args and kwargsiitindentt
separatorss
tmimetypetJSONIFY_MIMETYPEN(R[R\(s, s: (R6RR<tdebugRRNtresponse_classR(targsR?R^R_RP((s4/tmp/pip-install-sTXtzD/flask/flask/json/__init__.pyR2s1	
cKstt||��S(N(RR(RUR?((s4/tmp/pip-install-sTXtzD/flask/flask/json/__init__.pyt
tojson_filterws('R0RHRR#RRtitsdangerousRR*tjinja2Rt
werkzeug.httpRt_compatRRtglobalsRRR&tImportErrorR6RRZt__all__RRRRRBRDRRR
R
RRRRRe(((s4/tmp/pip-install-sTXtzD/flask/flask/json/__init__.pyt<module>sR

			*	+		%		E

https://t.me/AnonymousX5 - 2025