
    Ng                       d Z 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
Z
ddlZddlmZ ddlmZmZ ddlmZ ddlmZmZmZ ddlmZ dd	lmZmZmZmZmZmZ dd
l m!Z! ddl"m#Z#m$Z$ ddl%m&Z& ddl'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0 ddl1m2Z2 d Z3ddZ4 G d de          Z5 G d d          Z6 G d dej7        e5          Z8e8Z9dS )zLThe :class:`Schema` class, including its metaclass and options (class Meta).    )annotationsN)ABCMeta)OrderedDictdefaultdict)Mapping)baseclass_registrytypes)fields)	POST_DUMP	POST_LOADPRE_DUMPPRE_LOAD	VALIDATESVALIDATES_SCHEMA)
ErrorStore)StringNotCollectionErrorValidationError)
OrderedSet)	EXCLUDEINCLUDERAISE	get_valueis_collectionis_instance_or_subclassmissing	set_value validate_unknown_parameter_value)RemovedInMarshmallow4Warningc                >    d |                                  D             S )zKGet fields from a class

    :param attrs: Mapping of class attributes
    c                P    g | ]#\  }}t          |t          j                  ||f$S  )r   r   FieldABC).0
field_namefield_values      N/var/www/html/ai-engine/env/lib/python3.11/site-packages/marshmallow/schema.py
<listcomp>z_get_fields.<locals>.<listcomp>1   sC       #J";>>	[!      )items)attrss    r'   _get_fieldsr,   ,   s+    
 ',{{}}   r)   klass
SchemaMetac                p    t          j        |           }t          d |ddd         D             g           S )a  Collect fields from a class, following its method resolution order. The
    class itself is excluded from the search; only its parents are checked. Get
    fields from ``_declared_fields`` if available, else use ``__dict__``.

    :param type klass: Class whose fields to retrieve
    c              3  \   K   | ]'}t          t          |d |j                            V  (dS )_declared_fieldsN)r,   getattr__dict__)r$   r   s     r'   	<genexpr>z%_get_fields_by_mro.<locals>.<genexpr>D   sT       	
 	
  0$-@@ 	
 	
 	
 	
 	
 	
r)   Nr   )inspectgetmrosum)r-   mros     r'   _get_fields_by_mror:   :   sR     .

C	
 	
 EQrE
		
 	
 	
 	  r)   c                  P     e Zd ZdZ fdZeefdd	            Z fd
ZddZ	 xZ
S )r.   a  Metaclass for the Schema class. Binds the declared fields to
    a ``_declared_fields`` attribute, which is a dictionary mapping attribute
    names to field objects. Also sets the ``opts`` class attribute, which is
    the Schema class's ``class Meta`` options.
    c                N   |                     d          }t          |dd          }|s:|D ]5}t          |d          r#t          |j        d          r|j        j        } n6d}t          |          }|D ]\  }}	||= 	t                                          | |||          }
t          |
          }|
j        }|
	                    ||          |
_
        |t          |
j
        j                                                  z  }|                     |
||t                    |
_        |
S )NMetaorderedF)r>   )r-   
cls_fieldsinherited_fieldsdict_cls)getr2   hasattrr=   r>   r,   super__new__r:   OPTIONS_CLASSoptslistincluder*   get_declared_fieldsdictr1   )mcsnamebasesr+   metar>   base_r?   r%   _r-   r@   	__class__s               r'   rE   zSchemaMeta.__new__U   sF   yy  $	511 
	 
     5&)) gej).L.L #j0GE ''
 ( 	" 	"MJj!!T5%88-e44z ((w(??
d5:-3355666
 "%!8!8!-	 "9 "
 "
 r)   r-   r?   rH   r@   rA   
type[dict]c                     |||z             S )a	  Returns a dictionary of field_name => `Field` pairs declared on the class.
        This is exposed mainly so that plugins can add additional fields, e.g. fields
        computed from class Meta options.

        :param klass: The class object.
        :param cls_fields: The fields declared on the class, including those added
            by the ``include`` class Meta option.
        :param inherited_fields: Inherited fields.
        :param dict_cls: dict-like class to use for dict output Default to ``dict``.
        r"   )rL   r-   r?   r@   rA   s        r'   rJ   zSchemaMeta.get_declared_fields{   s    $ x(:5666r)   c                    t                                          |||           |r!| j        j        rt	          j        ||            |                                 | _        d S N)rD   __init__rG   registerr	   resolve_hooks_hooks)clsrM   rN   r+   rR   s       r'   rW   zSchemaMeta.__init__   s]    ue,,, 	/CH% 	/#D#...&&((


r)   return'dict[str, list[tuple[str, bool, dict]]]c                x   t          j        |           }t          t                    }t	          |           D ]|D ]!}	 |j                 } n# t          $ r Y w xY w'	 |j        }|                                D ],\  }}||         	                    fd|D                        -q# t          $ r Y }w xY w|S )zAdd in the decorated processors

        By doing this after constructing the class, we let standard inheritance
        do all the hard work.
        c              3  (   K   | ]\  }}||fV  d S rV   r"   )r$   manykwargs	attr_names      r'   r4   z+SchemaMeta.resolve_hooks.<locals>.<genexpr>   s?       & &6BdFD&1& & & & & &r)   )r6   r7   r   rH   dirr3   KeyError__marshmallow_hook__r*   extendAttributeError)	r[   r9   hooksparentattrhook_configtagconfigrb   s	           @r'   rY   zSchemaMeta.resolve_hooks   s+    nS!!D!!S 	 	I   !?95D E     H 
"7 $/#4#4#6#6  KC #J%% & & & &FL& & &     "    s$    A
AA!B**
B76B7)r-   r.   r?   rH   r@   rH   rA   rS   )r\   r]   )__name__
__module____qualname____doc__rE   classmethodrK   rJ   rW   rY   __classcell__)rR   s   @r'   r.   r.   N   s         $ $ $ $ $L   $7 7 7 7 [7&) ) ) ) )' ' ' ' ' ' ' 'r)   c                      e Zd ZdZdddZdS )	
SchemaOptsz=class Meta options for the :class:`Schema`. Defines defaults.Fr>   boolc                   t          |dd          | _        t          | j        t          t          f          st          d          t          |dd          | _        t          | j        t          t          f          st          d          | j        r| j        rt          d          t          |dd          | _        t          | j        t          t          f          st          d          t          |d	d           | _        t          |d
d           | _	        t          |dd           | _
        t          |d          r3t          j        dt          d           t          |dt                    }nt          }t          |d|          | _        t          |d|          | _        t          |dd          | _        t          |di           | _        t          |dd          | _        t          |dd          | _        t-          t          |dt.                              | _        t          |dd          | _        t          |dd          | _        d S )Nr   r"   z(`fields` option must be a list or tuple.
additionalz,`additional` option must be a list or tuple.zFCannot set both `fields` and `additional` options for the same Schema.excludez"`exclude` must be a list or tuple.
dateformatdatetimeformat
timeformatjson_modulezKThe json_module class Meta option is deprecated. Use render_module instead.   )
stacklevelrender_moduler>   index_errorsTrI   	load_only	dump_onlyunknownrX   r`   F)r2   r   
isinstancerH   tuple
ValueErrorrx   ry   rz   r{   r|   rC   warningswarnr   jsonr   r>   r   rI   r   r   r   r   r   rX   r`   )selfrO   r>   r   s       r'   rW   zSchemaOpts.__init__   s"   dHb11$+e}55 	IGHHH!$b99$/D%=99 	MKLLL; 	4? 	(   tY33$,u66 	CABBB!$d;;%d,<dCC!$d;;4'' 	!M],   
 $D->>MM M$T?MJJtY88#D.$??tY33 {B77 {B777iQV8W8WXXj$77D&%00			r)   N)F)r>   rv   )rn   ro   rp   rq   rW   r"   r)   r'   ru   ru      s3        GG#1 #1 #1 #1 #1 #1 #1r)   ru   c                     e Zd ZdZeej        eej        ej	        ej
        eej        eej        eej        eej        eej        eej        ej        ej        ej        ej        ej        ej        ej        ej        ej        ej        iZi Z dddZ!e"Z#e$Z%dZ&i Z'i Z( G d d          Z)ddddddddd	d[dZ*d\dZ+e,d]d            Z-e.ddd^d$            Z/d_d*Z0d`d.Z1e2dd/d0            Z3d1d2dad3Z4dd2dbd4Z5dd2dbd5Z6d1de7dd6dcd;Z8dddd<ddd=Z9dddd<ded?Z:dd/d@Z;dddAdfdCZ<ddddDdEdgdGZ=dhdIZ>dhdJZ?dhdKZ@didOZAdidPZBddQdjdSZCdkdTZDdldUZEd1dVdmdYZFddQdndZZGdS )oSchemaaD	  Base schema class with which to define custom schemas.

    Example usage:

    .. code-block:: python

        import datetime as dt
        from dataclasses import dataclass

        from marshmallow import Schema, fields


        @dataclass
        class Album:
            title: str
            release_date: dt.date


        class AlbumSchema(Schema):
            title = fields.Str()
            release_date = fields.Date()


        album = Album("Beggars Banquet", dt.date(1968, 12, 6))
        schema = AlbumSchema()
        data = schema.dump(album)
        data  # {'release_date': '1968-12-06', 'title': 'Beggars Banquet'}

    :param only: Whitelist of the declared fields to select when
        instantiating the Schema. If None, all fields are used. Nested fields
        can be represented with dot delimiters.
    :param exclude: Blacklist of the declared fields to exclude
        when instantiating the Schema. If a field appears in both `only` and
        `exclude`, it is not used. Nested fields can be represented with dot
        delimiters.
    :param many: Should be set to `True` if ``obj`` is a collection
        so that the object will be serialized to a list.
    :param context: Optional context passed to :class:`fields.Method` and
        :class:`fields.Function` fields.
    :param load_only: Fields to skip during serialization (write-only fields)
    :param dump_only: Fields to skip during deserialization (read-only fields)
    :param partial: Whether to ignore missing fields and not require
        any fields declared. Propagates down to ``Nested`` fields as well. If
        its value is an iterable, only missing fields listed in that iterable
        will be ignored. Use dot delimiters to specify nested fields.
    :param unknown: Whether to exclude, include, or raise an error for unknown
        fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.

    .. versionchanged:: 3.0.0
        `prefix` parameter removed.

    .. versionchanged:: 2.0.0
        `__validators__`, `__preprocessors__`, and `__data_handlers__` are removed in favor of
        `marshmallow.decorators.validates_schema`,
        `marshmallow.decorators.pre_load` and `marshmallow.decorators.post_dump`.
        `__accessor__` and `__error_handler__` are deprecated. Implement the
        `handle_error` and `get_attribute` methods instead.
    zInvalid input type.zUnknown field.)typer   Nc                      e Zd ZdZdS )Schema.Metaa  Options object for a Schema.

        Example usage: ::

            class Meta:
                fields = ("id", "email", "date_created")
                exclude = ("password", "secret_attribute")

        Available options:

        - ``fields``: Tuple or list of fields to include in the serialized result.
        - ``additional``: Tuple or list of fields to include *in addition* to the
            explicitly declared fields. ``additional`` and ``fields`` are
            mutually-exclusive options.
        - ``include``: Dictionary of additional fields to include in the schema. It is
            usually better to define fields as class variables, but you may need to
            use this option, e.g., if your fields are Python keywords. May be an
            `OrderedDict`.
        - ``exclude``: Tuple or list of fields to exclude in the serialized result.
            Nested fields can be represented with dot delimiters.
        - ``many``: Whether the data is a collection by default.
        - ``dateformat``: Default format for `Date <fields.Date>` fields.
        - ``datetimeformat``: Default format for `DateTime <fields.DateTime>` fields.
        - ``timeformat``: Default format for `Time <fields.Time>` fields.
        - ``render_module``: Module to use for `loads <Schema.loads>` and `dumps <Schema.dumps>`.
            Defaults to `json` from the standard library.
        - ``ordered``: If `True`, output of `Schema.dump` will be a `collections.OrderedDict`.
        - ``index_errors``: If `True`, errors dictionaries will include the index
            of invalid items in a collection.
        - ``load_only``: Tuple or list of fields to exclude from serialized results.
        - ``dump_only``: Tuple or list of fields to exclude from deserialization
        - ``unknown``: Whether to exclude, include, or raise an error for unknown
            fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
        - ``register``: Whether to register the `Schema` with marshmallow's internal
            class registry. Must be `True` if you intend to refer to this `Schema`
            by class name in `Nested` fields. Only set this to `False` when memory
            usage is critical. Defaults to `True`.
        N)rn   ro   rp   rq   r"   r)   r'   r=   r   E  s        %	 %	 %	 %	r)   r=   r"   )onlyry   r`   contextr   r   partialr   r   types.StrSequenceOrSet | Nonery   types.StrSequenceOrSetr`   bool | Noner   dict | Noner   r   r   $bool | types.StrSequenceOrSet | Noner   
str | Nonec                  |t          |          st          d          t          |          st          d          t          j        | j                  | _        || j        j        n|| _        || _        t          | j        j
                  t          |          z  | _
        | j        j        | _        t          |          pt          | j        j                  | _        t          |          pt          | j        j                  | _        || _        || j        j        nt!          |          | _        |pi | _        |                                  i | _        i | _        i | _        |                                  i }	|	                    | j                   t3          | j        j                  D ]&}
|	                    t9          |
di                      '|	                    | j        pi            |	| _        d S )Nz""only" should be a list of stringsz%"exclude" should be a list of stringserror_messages)r   r   copydeepcopyr1   declared_fieldsrG   r`   r   setry   r>   r   r   r   r   r   r   _normalize_nested_optionsr   load_fieldsdump_fields_init_fieldsupdate_default_error_messagesreversedrR   __mro__r2   r   )r   r   ry   r`   r   r   r   r   r   messagesr[   s              r'   rW   zSchema.__init__m  s    M$$7$7*+OPPPW%% 	T*+RSSS#}T-BCC&*lDINN		HKII
 I
LLI y(YC3ty/B+C+CYC3ty/B+C+C  I1':: 	
 }"&&(((4555DN233 	@ 	@COOGC)92>>????+1r222&r)   r\   strc                2    d| j         j         d| j         dS )N<z(many=z)>)rR   rn   r`   r   s    r'   __repr__zSchema.__repr__  s"    ?4>*??$)????r)   rS   c                ,    | j         rt          S t          S rV   )r>   r   rK   r   s    r'   
dict_classzSchema.dict_class  s    < 	Kr)   GeneratedSchema)rM   r   2dict[str, ma_fields.Field | type[ma_fields.Field]]rM   type[Schema]c                   |                                 }t          dt          | dt                    fddi          |d<   t          || f|          }|S )a  Generate a `Schema` class given a dictionary of fields.

        .. code-block:: python

            from marshmallow import Schema, fields

            PersonSchema = Schema.from_dict({"name": fields.Str()})
            print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

        Generated schemas are not added to the class registry and therefore cannot
        be referred to by name in `Nested` fields.

        :param dict fields: Dictionary mapping field names to field instances.
        :param str name: Optional name for the class, which will appear in
            the ``repr`` for the class.

        .. versionadded:: 3.0.0
        GeneratedMetar=   rX   F)r   r   r2   object)r[   r   rM   r+   
schema_clss        r'   	from_dictzSchema.from_dict  sZ    2 gc66::<z5>Q
 
f $..
r)   errorr   data
typing.Anyrv   c                   dS )a  Custom error handler function for the schema.

        :param error: The `ValidationError` raised during (de)serialization.
        :param data: The original input data.
        :param many: Value of ``many`` on dump or load.
        :param partial: Value of ``partial`` on load.

        .. versionadded:: 2.0.0

        .. versionchanged:: 3.0.0rc9
            Receives `many` and `partial` (on deserialization) as keyword arguments.
        Nr"   )r   r   r   r`   ra   s        r'   handle_errorzSchema.handle_error  s	     	r)   objrj   defaultc                $    t          |||          S )zDefines how to pull values from an object to serialize.

        .. versionadded:: 2.0.0

        .. versionchanged:: 3.0.0a1
            Changed position of ``obj`` and ``attr``.
        )r   )r   r   rj   r   s       r'   get_attributezSchema.get_attribute  s     dG,,,r)   indexc                   	  | |          }nB# t           $ r5}|                    |j        ||           |j        pt          cY d}~S d}~ww xY w|S )a  Call ``getter_func`` with ``data`` as its argument, and store any `ValidationErrors`.

        :param callable getter_func: Function for getting the serialized/deserialized
            value from ``data``.
        :param data: The data passed to ``getter_func``.
        :param str field_name: Field name.
        :param int index: Index of the item being validated, if validating a collection,
            otherwise `None`.
        r   N)r   store_errorr   
valid_datar   )getter_funcr   r%   error_storer   valuer   s          r'   _call_and_storezSchema._call_and_store  sz    	/K%%EE 	/ 	/ 	/##ENJe#LLL #.w......		/
 s    
A*AAAFr`   c               
    |r| fd|D             S                                   } j                                        D ]A\  }}|                    || j                  }|t
          u r,|j        |j        n|}|||<   B|S )a  Serialize ``obj``.

        :param obj: The object(s) to serialize.
        :param bool many: `True` if ``data`` should be serialized as a collection.
        :return: A dictionary of the serialized data

        .. versionchanged:: 1.0.0
            Renamed from ``marshal``.
        Nc                >    g | ]}                     |d           S )Fr   )
_serialize)r$   dr   s     r'   r(   z%Schema._serialize.<locals>.<listcomp>  s)    @@@qDOOAEO22@@@r)   )accessor)r   r   r*   	serializer   r   data_key)r   r   r`   retrb   	field_objr   keys   `       r'   r   zSchema._serialize  s      	ACO@@@@C@@@@oo$($4$:$:$<$< 	 	 Iy''	3AS'TTE(1(:(F)$$ICCHH
r)   c               *   || j         nt          |          }| j        t                   r|                     t          |||          }n|}|                     ||          }| j        t                   r|                     t          |||          }|S )a  Serialize an object to native Python data types according to this
        Schema's fields.

        :param obj: The object to serialize.
        :param many: Whether to serialize `obj` as a collection. If `None`, the value
            for `self.many` is used.
        :return: Serialized data

        .. versionadded:: 1.0.0
        .. versionchanged:: 3.0.0b7
            This method returns the serialized data rather than a ``(data, errors)`` duple.
            A :exc:`ValidationError <marshmallow.exceptions.ValidationError>` is raised
            if ``obj`` is invalid.
        .. versionchanged:: 3.0.0rc9
            Validation no longer occurs upon serialization.
        N)r`   original_datar   )r`   rv   rZ   r   _invoke_dump_processorsr   r   )r   r   r`   processed_objresults        r'   dumpzSchema.dump  s    " !Ltyyd4jj;x  	  88#D 9  MM  MT::;y! 	116C 2  F r)   c               f    |                      ||          } | j        j        j        |g|R i |S )a+  Same as :meth:`dump`, except return a JSON-encoded string.

        :param obj: The object to serialize.
        :param many: Whether to serialize `obj` as a collection. If `None`, the value
            for `self.many` is used.
        :return: A ``json`` string

        .. versionadded:: 1.0.0
        .. versionchanged:: 3.0.0b7
            This method returns the serialized data rather than a ``(data, errors)`` duple.
            A :exc:`ValidationError <marshmallow.exceptions.ValidationError>` is raised
            if ``obj`` is invalid.
        r   )r   rG   r   dumps)r   r   r`   argsra   
serializeds         r'   r   zSchema.dumps0  sA     YYsY..
,ty&,ZI$III&IIIr)   )r`   r   r   r   Rtyping.Mapping[str, typing.Any] | typing.Iterable[typing.Mapping[str, typing.Any]]r   r   typing.Any | list[typing.Any]c               l     j         j        }|r|nd}|rUt                    s&                     j        d         g|           g }n fdt                    D             }|S                                  }	t          t                    s%                     j        d         g|           nut                    }
 j	        
                                D ]\  }}|j        |j        n|}                    |t                    }|t          u rdu s|
r|v rDi }|
r)|dz   t                    fdD             }||d<   n|d<   |||ffd		}                     ||||
          }|t          ur|j        p|}t#          |	||           t$          k    rd  j	        
                                D             }t'                    |z
  D ]M}|         }t(          k    r||	|<   t*          k    r'                     j        d         g||r|nd           N|	S )a  Deserialize ``data``.

        :param dict data: The data to deserialize.
        :param ErrorStore error_store: Structure to store errors.
        :param bool many: `True` if ``data`` should be deserialized as a collection.
        :param bool|tuple partial: Whether to ignore missing fields and not require
            any fields declared. Propagates down to ``Nested`` fields as well. If
            its value is an iterable, only missing fields listed in that iterable
            will be ignored. Use dot delimiters to specify nested fields.
        :param unknown: Whether to exclude, include, or raise an error for unknown
            fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
        :param int index: Index of the item being serialized (for storing errors) if
            serializing a collection, otherwise `None`.
        :return: The deserialized data as `dict_class` instance or list of `dict_class`
        instances if `many` is `True`.
        Nr   r   c           
     |    g | ]8\  }}                     t          j        t          |          d |          9S )F)r   r`   r   r   r   )_deserializetypingcastrK   )r$   idxr   r   r   r   r   s      r'   r(   z'Schema._deserialize.<locals>.<listcomp>e  sb     
 
 
 Q %%D!,,$/" ' '! &  
 
 
r)   T.c                N    g | ]!}|                               |d          "S rV   )
startswith)r$   f
len_prefixprefixs     r'   r(   z'Schema._deserialize.<locals>.<listcomp>  sB     # # #+,1<<;O;O#*++# # #r)   r   c                $     |j         | |fi |S rV   )deserialize)valr   r%   d_kwargsr   s       r'   getterz#Schema._deserialize.<locals>.getter  s4     190"  #	  r)   r   r   r%   r   r   c                4    h | ]\  }}|j         |j         n|S rV   r   )r$   r%   r   s      r'   	<setcomp>z&Schema._deserialize.<locals>.<setcomp>  s<       -
I +4*<*HI&&j  r)   r   )rG   r   r   r   r   	enumerater   r   r   r   r*   r   rB   r   lenr   	attributer   r   r   r   r   )r   r   r   r`   r   r   r   r   ret_lret_dpartial_is_collectionrb   r   r%   	raw_valuer   sub_partialr   r   r   r   r   r   s   ``` ``               @@r'   r   zSchema._deserializeA  s$   : y-%/4 	 && '')<V)D(EU'SSS
 
 
 
 
 
 
 #,D//
 
 
 L!!$(( =	##T%8%@$A#OOOO$1'$:$:!(,(8(>(>(@(@ *1 *1$	9*3*<*HI&&i  !HHZ99	''$- '2;w2F2F ( 2'#-F!$VJ# # # # #07# # #K +6HY''(*1HY' $-h      ,, &") + -   ''#-:CeS%000'!! 151A1G1G1I1I   t99v- 	 	C IE'))%*c

 E))#//!0;<&2<UU  
 r)   r`   r   r   c               6    |                      ||||d          S )aR  Deserialize a data structure to an object defined by this Schema's fields.

        :param data: The data to deserialize.
        :param many: Whether to deserialize `data` as a collection. If `None`, the
            value for `self.many` is used.
        :param partial: Whether to ignore missing fields and not require
            any fields declared. Propagates down to ``Nested`` fields as well. If
            its value is an iterable, only missing fields listed in that iterable
            will be ignored. Use dot delimiters to specify nested fields.
        :param unknown: Whether to exclude, include, or raise an error for unknown
            fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
            If `None`, the value for `self.unknown` is used.
        :return: Deserialized data

        .. versionadded:: 1.0.0
        .. versionchanged:: 3.0.0b7
            This method returns the deserialized data rather than a ``(data, errors)`` duple.
            A :exc:`ValidationError <marshmallow.exceptions.ValidationError>` is raised
            if invalid data are passed.
        Tr`   r   r   postprocess)_do_load)r   r   r`   r   r   s        r'   loadzSchema.load  s*    > }}tWg4  
 
 	
r)   	json_datac               d     | j         j        j        |fi |}|                     ||||          S )aZ  Same as :meth:`load`, except it takes a JSON string as input.

        :param json_data: A JSON string of the data to deserialize.
        :param many: Whether to deserialize `obj` as a collection. If `None`, the
            value for `self.many` is used.
        :param partial: Whether to ignore missing fields and not require
            any fields declared. Propagates down to ``Nested`` fields as well. If
            its value is an iterable, only missing fields listed in that iterable
            will be ignored. Use dot delimiters to specify nested fields.
        :param unknown: Whether to exclude, include, or raise an error for unknown
            fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
            If `None`, the value for `self.unknown` is used.
        :return: Deserialized data

        .. versionadded:: 1.0.0
        .. versionchanged:: 3.0.0b7
            This method returns the deserialized data rather than a ``(data, errors)`` duple.
            A :exc:`ValidationError <marshmallow.exceptions.ValidationError>` is raised
            if invalid data are passed.
        r   )rG   r   loadsr  )r   r  r`   r   r   ra   r   s          r'   r  zSchema.loads  s=    : -ty&,YAA&AAyyD'7yKKKr)   c                   	 |r |||||           d S  ||||           d S # t           $ r-}	|                    |	j        |	j        |           Y d }	~	d S d }	~	ww xY w)N)r   r`   r   )r   r   r   r%   )
r   validator_funcoutputr   r   r`   r   pass_originalr   errs
             r'   _run_validatorzSchema._run_validator  s    	O Cv}gDQQQQQQvwTBBBBBB 	O 	O 	O##CL#.#NNNNNNNNN	Os   % % 
A"AAr`   r   dict[str, list[str]]c                   	 |                      |||d           nS# t          $ rF}t          j        t          t
          t          t
                   f         |j                  cY d}~S d}~ww xY wi S )a  Validate `data` against the schema, returning a dictionary of
        validation errors.

        :param data: The data to validate.
        :param many: Whether to validate `data` as a collection. If `None`, the
            value for `self.many` is used.
        :param partial: Whether to ignore missing fields and not require
            any fields declared. Propagates down to ``Nested`` fields as well. If
            its value is an iterable, only missing fields listed in that iterable
            will be ignored. Use dot delimiters to specify nested fields.
        :return: A dictionary of validation errors.

        .. versionadded:: 1.1.0
        F)r`   r   r  N)r  r   r   r   rK   r   rH   r   )r   r   r`   r   excs        r'   validatezSchema.validate
  s}    0	CMM$T7MNNNN 	C 	C 	C;tCcN3S\BBBBBBBB	C	s    
A,;A'!A,'A,Tr   r  c          	        t                      }i }|| j        nt          |          }|| j        nt	          |          }|| j        }| j        t                   rN	 |                     t          ||||          }n/# t          $ r }	|	
                                }d}
Y d}	~	n
d}	~	ww xY w|}|s|                     |||||          }
|                     ||
|           | j        t                   rLt          |j                  }|                     |d|
||||           |                     |d|
||||           |j        }|s`|r^| j        t                    rL	 |                     t           |
|||          }
n+# t          $ r}	|	
                                }Y d}	~	nd}	~	ww xY w|r-t          |||
          }|                     ||||	           ||
S )
ar  Deserialize `data`, returning the deserialized result.
        This method is private API.

        :param data: The data to deserialize.
        :param many: Whether to deserialize `data` as a collection. If `None`, the
            value for `self.many` is used.
        :param partial: Whether to validate required fields. If its
            value is an iterable, only fields listed in that iterable will be
            ignored will be allowed missing. If `True`, all fields will be allowed missing.
            If `None`, the value for `self.partial` is used.
        :param unknown: Whether to exclude, include, or raise an error for unknown
            fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
            If `None`, the value for `self.unknown` is used.
        :param postprocess: Whether to run post_load methods..
        :return: Deserialized data
        N)r`   r   r   )r   r`   r   r   )r   r   r`   T)r   	pass_manyr   r   r`   r   field_errorsF)r   r   r  )r   r`   rv   r   r   r   rZ   r   _invoke_load_processorsr   normalized_messagesr   _invoke_field_validatorsr   errors_invoke_schema_validatorsr   r   )r   r   r`   r   r   r  r   r  processed_datar  r   r  r  s                r'   r  zSchema._do_load*  s   8 !ll Ltyyd4jj  LL1':: 	
 ?lG;x  		"!%!=!=dT7 "> " " #   0022 "N .	7&&' '  F ))'f4 *    {+, #K$677.. +""&#!- /    .. +#"&#!- /    !'F 
7k 
7dk).D 
7	7!99!!&* ' :  FF ' 7 7 7 4466FFFFFF7 	!&tGGGCc4dGDDDIs0   A= =
B'B""B'E< <
F$FF$Nonec                :   | j         E|                     d| j         d           |                     d | j         D                       | _         | j        rG|                     d| j        d           |                     d | j        D                       | _        dS dS )zVApply then flatten nested schema options.
        This method is private API.
        Nr   intersectionc                F    g | ]}|                     d d          d         S )r      r   splitr$   fields     r'   r(   z4Schema._normalize_nested_options.<locals>.<listcomp>  s+    'V'V'V5C(;(;A(>'V'V'Vr)   ry   unionc                    g | ]}d |v|	S )r   r"   r"  s     r'   r(   z4Schema._normalize_nested_options.<locals>.<listcomp>  s"    EEE5Cu4D4D4D4D4Dr)   )r   _Schema__apply_nested_option	set_classry   r   s    r'   r   z Schema._normalize_nested_options  s     9 &&vty.III'V'VDI'V'V'VWWDI< 	&&y$,HHH>>EEDLEEE DLLL		 	r)   c                   d |D             }t          t                    }|D ] \  }}||                             |           !t          |                                          D ]\  }}	|                     |	          }
t          | j        |         |d          }|r<|dk    r|
|                     |          z  }
|dk    r|
|                     |          z  }
t          | j        |         ||
           dS )z%Apply nested options to nested fieldsc                B    g | ]}d |v |                     d d          S )r   r  r   )r$   rM   s     r'   r(   z0Schema.__apply_nested_option.<locals>.<listcomp>  s+    SSSsd{{C++{{{r)   r"   r$  r  N)	r   rH   appenditerr*   r'  r2   r   setattr)r   option_namefield_namesset_operationnested_fieldsnested_optionsri   nested_namesr   optionsnew_optionsoriginal_optionss               r'   __apply_nested_optionzSchema.__apply_nested_option  s    TSSSS$T**$1 	8 	8 FL6")),7777 !5!5!7!788 	I 	ILC..11K&t';C'@+rRR D G++4>>2B#C#CCK N224>>2B#C#CCKD(-{KHHHH	I 	Ir)   c                   | j         j        r |                     | j         j                  }nZ|                     | j                                                  }| j         j        r"||                     | j         j                  z  }|                                 }| j        #|                     | j                  }|||z
  z  }n|}| j        r|| j        z
  }|| j        |z
  z  }|rd|  d| d}t          |          | 	                                }|D ]I}| j        
                    |t          j                              }|                     ||           |||<   J| 	                                | 	                                }	}|                                D ]\  }}|j        s|||<   |j        s||	|<   d |	                                D             t#                    t#          t%                              k    r-fdD             }
t          dt'          |
                     d |                                D             t#                    t#          t%                              k    r-fd	D             }t          d
t'          |                     || _        |	| _        || _        dS )zUpdate self.fields, self.load_fields, and self.dump_fields based on schema options.
        This method is private API.
        NzInvalid fields for z: r   c                4    g | ]\  }}|j         |j         n|S rV   r   )r$   rM   r   s      r'   r(   z'Schema._init_fields.<locals>.<listcomp>  s<     
 
 
i #,"4"@Id
 
 
r)   c                F    h | ]}                     |          d k    |S r  count)r$   xdump_data_keyss     r'   r   z&Schema._init_fields.<locals>.<setcomp>  s8     $ $ $^-A-A!-D-Dq-H-H-H-H-Hr)   zThe data_key argument for one or more fields collides with another field's name or data_key argument. Check the following field names and data_key arguments: c                &    g | ]\  }}|j         p|S r"   )r   )r$   rM   r   s      r'   r(   z'Schema._init_fields.<locals>.<listcomp>  s#    VVVYT33=0DVVVr)   c                F    h | ]}                     |          d k    |S r:  r;  )r$   r=  load_attributess     r'   r   z&Schema._init_fields.<locals>.<setcomp>  s8     % % %o.C.CA.F.F.J.J.J.J.Jr)   zThe attribute argument for one or more fields collides with another field's name or attribute argument. Check the following field names and attribute arguments: )rG   r   r'  r   keysrx   r   ry   r   r   rB   	ma_fieldsInferred_bind_fieldr*   r   r   r   r   rH   r   r   )r   available_field_namesinvalid_fieldsr.  messagefields_dictr%   r   r   r   data_keys_duplicatesattributes_duplicatesr>  rA  s               @@r'   r   zSchema._init_fields  sL    9 	N$(NN493C$D$D!!$(NN43G3L3L3N3N$O$O!y# N%	8L)M)MM%))9 :>..:S:SKk,AAANN/K < 	C &4Kdl-BBBN 	&EDEENEEEGW%%%oo''% 	0 	0J,00Y=O=Q=QRRIZ333&/K
###'??#4#4doo6G6G[%0%6%6%8%8 	4 	4!J	& 4*3J'& 4*3J'
 
#.#4#4#6#6
 
 
 ~#c.&9&9":":::$ $ $ $)$ $ $  D (,,@'A'AD D   WV+BSBSBUBUVVV3s?';';#<#<<<% % % %*% % %! F )--B(C(CF F   "&&r)   r%   r   ma_fields.Fieldc                    dS )z\Hook to modify a field when it is bound to the `Schema`.

        No-op by default.
        Nr"   )r   r%   r   s      r'   on_bind_fieldzSchema.on_bind_field   s	    
 tr)   c                d   || j         v rd|_         || j        v rd|_        	 |                    ||            na# t          $ rT}t	          |t
                    r8t          |t          j                  rd| d|j	         d}t          |          ||d}~ww xY w| 
                    ||           dS )zBind field to the schema, setting any necessary attributes on the
        field (e.g. parent and name).

        Also set field load_only and dump_only values if field_name was
        specified in ``class Meta``.
        TzField for "zJ" must be declared as a Field instance, not a class. Did you mean "fields.z()"?N)r   r   _bind_to_schema	TypeErrorr   r   
issubclassr   r#   rn   rN  )r   r%   r   r   msgs        r'   rE  zSchema._bind_field  s     ''"&I''"&I	%%j$7777 	 	 	 )T** 0z)T]/S/S 0E* E E,5,>E E E 
  nn%/K	 	:y11111s   9 
BABB)r   rl   c               n    |                      |d|||          }|                      |d|||          }|S )NF)r  r   r`   r   T_invoke_processors)r   rl   r   r`   r   s        r'   r   zSchema._invoke_dump_processors"  sW     &&5t$m ' 
 
 &&4d] ' 
 
 r)   c               r    |                      |d||||          }|                      |d||||          }|S )NT)r  r   r`   r   r   FrU  )r   rl   r   r`   r   r   s         r'   r  zSchema._invoke_load_processors0  se     &&' ' 
 
 &&' ' 
 
 r)   c          	        | j         t                   D ]P\  }}}t          | |          }|d         }	 | j        |         }	n4# t          $ r'}
|| j        v rY d }
~
Ft          d| d          |
d }
~
ww xY w|	j        |	j        n|}|rt          |          D ]r\  }}	 ||	j	        p|         }| 
                    ||||| j        j        r|nd           }|t          u r||                             |d            c# t          $ r Y ow xY w	 ||	j	        p|         }| 
                    ||||          }|t          u r|                    |d            A# t          $ r Y Nw xY wd S )Nr%   "z" field does not exist.r   )r   r   r%   r   )rZ   r   r2   r   rd   r   r   r   r   r   r   rG   r   r   pop)r   r   r   r`   rb   rQ   validator_kwargs	validatorr%   r   r   r   r   itemr   validated_values                   r'   r  zSchema._invoke_field_validatorsM  s   .2k).D +	3 +	3*Iq*i00I),7JU K
3		 U U U!555HHHH !HZ!H!H!HIIuTU '0&8&D	""*   3!*4 < <IC< $Y%8%FJ G +/*>*>(1!&'/(3*.)*@#J33d +? + + +g55 IMM*d;;; $   < 3 !4!B
CE '+&:&:$-"#+$/	 '; ' 'O ''11T222     DC+	3 +	3sA   A
A2	A-A--A2C99
DDE
E"!E")r  r  r  c               p   | j         t                   D ]\  }}	}
|	|k    rt          | |          }|r	|
d         r(|
                    dd          }|rF|sDt	          t          ||                    D ]%\  }\  }}|                     ||||||||           &|                     |||||||           d S )Nskip_on_field_errorsr
  F)r   r   r`   r   r   r
  )r   r   r`   r
  r   )rZ   r   r2   rB   r   zipr  )r   r   r  r   r   r`   r   r  rb   	hook_manyr[  r\  r
  r   r]  origs                   r'   r  z Schema._invoke_schema_validators{  s)    7;kBR6S 	 	2Iy"2I%%i00I  01G H ,00%HHM I )23t]3K3K)L)L 
 
%C$''!&*$/! '!&3 ( 	 	 	 	
 ##"/ +"/# $    +	 	r)   c               .   | j         |         D ]\  }}}	||k    rt          | |          |	                    dd          }
r4|s2|
rfdt          ||          D             }Xfd|D             }i|
r ||fdi}x |fdi}|S )Nr
  Fc                .    g | ]\  }} ||fd iS r   r"   )r$   r]  originalra   r`   	processors      r'   r(   z-Schema._invoke_processors.<locals>.<listcomp>  sF       *D( "	$FFtFvFF  r)   c                &    g | ]} |fd iS r   r"   )r$   r]  ra   r`   rg  s     r'   r(   z-Schema._invoke_processors.<locals>.<listcomp>  s0    RRRTIId@@@@@RRRr)   r`   )rZ   r2   rB   ra  )r   rl   r  r   r`   r   ra   rb   rb  processor_kwargsr
  rg  s       ` `    @r'   rV  zSchema._invoke_processors  s!    7;k#6F 	@ 	@2Iy"2I%%i00I,00%HHM @I @  S     .1$.F.F  DD
 SRRRRRTRRRDD  @$9T=NNtNvNNDD$9T?????DDr)   )r   r   ry   r   r`   r   r   r   r   r   r   r   r   r   r   r   )r\   r   )r\   rS   )r   r   rM   r   r\   r   )r   r   r   r   r`   rv   )r   r   rj   r   r   r   )r   r   r`   rv   )r   r   r`   r   )r   r   r   r   r`   rv   r\   r   )r   r   r`   r   r   r   r   r   )r  r   r`   r   r   r   r   r   )r   r   r`   r   r   r   r\   r  )
r   r   r`   r   r   r   r   r   r  rv   )r\   r  )r%   r   r   rL  r\   r  )rl   r   r`   rv   )rl   r   r`   rv   r   r   )r   r   r`   rv   )
r   r   r  rv   r`   rv   r   r   r  rv   )rl   r   r  rv   r`   rv   )Hrn   ro   rp   rq   r   rC  StringbytesdtdatetimeDateTimefloatFloatrv   Booleanr   RawrH   r   intIntegeruuidUUIDtimeTimedateDate	timedelta	TimeDeltadecimalDecimalTYPE_MAPPINGr   r   ru   rF   r   r'  rG   r1   rZ   r=   rW   r   propertyr   rr   r   r   r   staticmethodr   r   r   r   r   r   r  r  r  r  r  r   r&  r   rN  rE  r   r  r  r  rV  r"   r)   r'   r   r      sp       9 9x 	Yy
Y'yiy}imY]Y	9>


i)*L" N &# 
 MI DF& & & & & & & &V /3*, #,.,.8<"-' -' -' -' -' -'^@ @ @ @    X 
 &	     [B   "- - - - MQ     \& ;@      * <@            D AE J J J J J J2 p p p p p pr !8<"!
 !
 !
 !
 !
 !
N !8<"L L L L L LT O O O O O6 !8<     N !8<" e e e e e eN   "I I I I&I' I' I' I'V   2 2 2 28 <@        :,3 ,3 ,3 ,3n #( ( ( ( ( (b        r)   r   )	metaclass)r-   r.   ):rq   
__future__r   r   rm  rl  r}  r6   r   r   ru  r   abcr   collectionsr   r   collections.abcr   marshmallowr   r	   r
   r   rC  marshmallow.decoratorsr   r   r   r   r   r   marshmallow.error_storer   marshmallow.exceptionsr   r   marshmallow.orderedsetr   marshmallow.utilsr   r   r   r   r   r   r   r   r   marshmallow.warningsr   r,   r:   r.   ru   	SchemaABCr   
BaseSchemar"   r)   r'   <module>r     s   R R " " " " " "                  0 0 0 0 0 0 0 0 # # # # # # 3 3 3 3 3 3 3 3 3 3 + + + + + +                / . . . . . L L L L L L L L - - - - - -
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 > = = = = =	 	 	   (n n n n n n n nb&1 &1 &1 &1 &1 &1 &1 &1R[ [ [ [ [T^z [ [ [ [| 


r)   