HEX
Server: LiteSpeed
System: Linux us-phx-web1284.main-hosting.eu 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: u300739242 (300739242)
PHP: 8.2.30
Disabled: system, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/jsons/__pycache__/_load_impl.cpython-37.pyc
B

�P�e� �@s�dZddlZddlmZddlmZmZmZmZmZm	Z	ddl
mZddlm
Z
mZmZmZmZmZmZmZddlmZddlmZdd	lmZmZmZd"d
e
dd�eee	eeeeeee egeffed�d
d�Z!ee"eed�dd�Z#d#e ee	eeee efed�dd�Z$d$e%ee	ee eee efed�dd�Z&eeeeeeee'fd�dd�Z(eeed�dd�Z)eed�d d!�Z*dS)%zt
PRIVATE MODULE: do not import (from) it directly.

This module contains functionality for loading stuff from json.
�N)�JSONDecodeError)�Optional�Dict�Callable�Tuple�Any�Type)�clear)�StateHolder�get_cls_from_str�get_class_name�get_cls_and_meta�determine_precedence�VALID_TYPES�T�can_match_with_none)�get_deserializer)�validate)�DeserializationError�
JsonsError�DecodeErrorF)�strict�	fork_inst�attr_getters)�json_obj�clsrrr�returncKs�t||�t|||�r&t|||�|St|t�r<t|||�}|}t||||�dd��\}}t||�}|�dd�}	d|i||||d||k	d��}
t	||||	f|
�S)a�
    Deserialize the given ``json_obj`` to an object of type ``cls``. If the
    contents of ``json_obj`` do not match the interface of ``cls``, a
    DeserializationError is raised.

    If ``json_obj`` contains a value that belongs to a custom class, there must
    be a type hint present for that value in ``cls`` to let this function know
    what type it should deserialize that value to.


    **Example**:

    >>> from typing import List
    >>> import jsons
    >>> class Person:
    ...     # No type hint required for name
    ...     def __init__(self, name):
    ...         self.name = name
    >>> class Family:
    ...     # Person is a custom class, use a type hint
    ...         def __init__(self, persons: List[Person]):
    ...             self.persons = persons
    >>> loaded = jsons.load({'persons': [{'name': 'John'}]}, Family)
    >>> loaded.persons[0].name
    'John'

    If no ``cls`` is given, a dict is simply returned, but contained values
    (e.g. serialized ``datetime`` values) are still deserialized.

    If `strict` mode is off and the type of `json_obj` exactly matches `cls`
    then `json_obj` is simply returned.

    :param json_obj: the dict that is to be deserialized.
    :param cls: a matching class of which an instance should be returned.
    :param strict: a bool to determine if the deserializer should be strict
    (i.e. fail on a partially deserialized `json_obj` or on `None`).
    :param fork_inst: if given, it uses this fork of ``JsonSerializable``.
    :param attr_getters: a ``dict`` that may hold callables that return values
    for certain attributes.
    :param kwargs: the keyword args are passed on to the deserializer function.
    :return: an instance of ``cls`` if given, a dict otherwise.
    �
_inferred_clsF�_initialT�
meta_hints)rrrrr)
�_check_for_none�_should_skipr�
isinstance�strr�!_check_and_get_cls_and_meta_hints�getr�_do_load)rrrrr�kwargsZoriginal_clsr�deserializer�initial�kwargs_�r+�A/opt/alt/python37/lib/python3.7/site-packages/jsons/_load_impl.py�loads&2


r-)rr(rr)c	
Ks�t|dd�}|dkr&td�|�||��y"|||f|�}t|||d�WnPtk
r�}z2t�t|t�rl�d�|||�}t|||�|�Wdd}~XYnX|r�t�|SdS)NT)�fully_qualifiedzNo deserializer for type "{}"rz.Could not deserialize value "{}" into "{}". {})rr�formatr�	Exceptionr	r"r)	rr(rr)r'�cls_name�result�err�messager+r+r,r&hs
 r&)�str_r�jdkwargsrc
Osd|pi}ytj|f|�}Wn2tk
rL}ztd|||�|�Wdd}~XYnXt||f|�|�SdS)ak
    Extend ``json.loads``, allowing a string to be loaded into a dict or a
    Python instance of type ``cls``. Any extra (keyword) arguments are passed
    on to ``json.loads``.

    :param str_: the string that is to be loaded.
    :param cls: a matching class of which an instance should be returned.
    :param jdkwargs: extra keyword arguments for ``json.loads`` (not
    ``jsons.loads``!)
    :param args: extra arguments for ``jsons.loads``.
    :param kwargs: extra keyword arguments for ``jsons.loads``.
    :return: a JSON-type object (dict, str, list, etc.) or an instance of type
    ``cls`` if given.
    z:Could not load a dict; the given string is not valid JSON.N)�json�loadsrrr-)r5rr6�argsr'�objr3r+r+r,r8�sr8�utf-8)�bytes_r�encodingr6rcOsNt|t�s td�t|��||��|p&i}|j|d�}t||f|�d|i|��S)a�
    Extend ``json.loads``, allowing bytes to be loaded into a dict or a Python
    instance of type ``cls``. Any extra (keyword) arguments are passed on to
    ``json.loads``.

    :param bytes_: the bytes that are to be loaded.
    :param cls: a matching class of which an instance should be returned.
    :param encoding: the encoding that is used to transform from bytes.
    :param jdkwargs: extra keyword arguments for ``json.loads`` (not
    ``jsons.loads``!)
    :param args: extra arguments for ``jsons.loads``.
    :param kwargs: extra keyword arguments for ``jsons.loads``.
    :return: a JSON-type object (dict, str, list, etc.) or an instance of type
    ``cls`` if given.
    z(loadb accepts bytes only, "{}" was given)r=r6)r"�bytesrr/�type�decoder8)r<rr=r6r9r'r5r+r+r,�loadb�s
rA)rrr�inferred_clsrc
Cs�t|�tkrHtt|�dd�}dd�tD�}d�|d�|��}t|||��t||�\}}|rf|�di�ni}	t||t|�|�|	fS)NT)r.cSsg|]}t|dd��qS)T)r.)r)�.0�typr+r+r,�
<listcomp>�sz5_check_and_get_cls_and_meta_hints.<locals>.<listcomp>zIInvalid type: "{}", only arguments of the following types are allowed: {}z, �classes)	r?rrr/�joinrr
r%r)
rrrrBZinvalid_typeZvalid_types�msgZ
cls_from_meta�metarr+r+r,r$�sr$)rrrcCs|rt|�|kp|tkS)N)r?r)rrrr+r+r,r!�sr!)rrcCs0|dkr,t|�s,t|�}td�|�||d��dS)Nz'NoneType cannot be deserialized into {})r4�source�target)rrrr/)rrr1r+r+r,r �sr )N)NN)Nr;N)+�__doc__r7r�typingrrrrrrZjsons._cacher	Zjsons._common_implr
rrr
rrrrZjsons._lizers_implrZjsons._validationrZjsons.exceptionsrrr�object�boolr?r#r-�callabler&r8r>rA�dictr$r!r r+r+r+r,�<module>s< (
0G