
    zi*                    z   U d Z ddlmZ ddl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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 d	dlmZ  ej        d=i ej        ddi G d d                      Z ej        d=i ej        ddi G d d                      Zer_ee eeef         e!eef         ee         f         Z"de#d<   eej$        e"f         Z%eej&        e"f         Z' e
de%          Z( e
de'          Z)eddddd>d%            Z*eddddd?d(            Z*eddddd@d+            Z*d,ed-dd.dAd1Z* e
d2e	def                   Z+edBd4            Z,edd-dd5dCd7            Z,	 dDd,d-ed5dEd9Z, e
d:          Z-eree-df         Z.dS  ej        d=i ej         G d; d<                      Z.dS )FzEThis module contains related classes and functions for serialization.    )annotationsN)partialmethod)TYPE_CHECKINGAnyCallableTypeVarUnionoverload)PydanticUndefinedcore_schema)r   )	AnnotatedLiteral	TypeAlias   )PydanticUndefinedAnnotation)_decorators_internal_dataclass)GetCoreSchemaHandlerfrozenTc                  B    e Zd ZU dZded<   eZded<   dZded<   ddZdS )PlainSerializera  Plain serializers use a function to modify the output of serialization.

    Attributes:
        func: The serializer function.
        return_type: The return type for the function. If omitted it will be inferred from the type annotation.
        when_used: Determines when this serializer should be used. Accepts a string with values `'always'`,
            `'unless-none'`, `'json'`, and `'json-unless-none'`. Defaults to 'always'.
    zcore_schema.SerializerFunctionfuncr   return_typealways<Literal['always', 'unless-none', 'json', 'json-unless-none']	when_usedsource_typehandlerr   returncore_schema.CoreSchemac                    ||          }	 t          j        | j        | j        |                                          }n'# t
          $ r}t          j        |          |d}~ww xY w|t          u rdn|	                    |          }t          j        | j        t          j        | j        d          || j                  |d<   |S )zGets the Pydantic core schema.

        Args:
            source_type: The source type.
            handler: The `GetCoreSchemaHandler` instance.

        Returns:
            The Pydantic core schema.
        Nplainfunctioninfo_argreturn_schemar   serialization)r   get_function_return_typer   r   _get_types_namespace	NameErrorr   from_name_errorr   generate_schemar   $plain_serializer_function_ser_schemainspect_annotated_serializerr   selfr   r   schemar   er&   s          j/var/www/tmov.alphamb/tmov_inventario/venv/lib/python3.11/site-packages/pydantic/functional_serializers.py__get_pydantic_core_schema__z,PlainSerializer.__get_pydantic_core_schema__    s     %%	H%>	4+W-I-I-K-K KK  	H 	H 	H-=a@@aG	H +/@ @ @gF]F]^iFjFj"-"RY =diQQ'n	#
 #
 #
    2A   
A$
AA$Nr   r   r   r   r   r    	__name__
__module____qualname____doc____annotations__r   r   r   r4        r3   r   r      sd           )((((K((((NVIVVVV     r>   r   c                  B    e Zd ZU dZded<   eZded<   dZded<   ddZdS )WrapSerializeraS  Wrap serializers receive the raw inputs along with a handler function that applies the standard serialization
    logic, and can modify the resulting value before returning it as the final output of serialization.

    Attributes:
        func: The serializer function to be wrapped.
        return_type: The return type for the function. If omitted it will be inferred from the type annotation.
        when_used: Determines when this serializer should be used. Accepts a string with values `'always'`,
            `'unless-none'`, `'json'`, and `'json-unless-none'`. Defaults to 'always'.
    z"core_schema.WrapSerializerFunctionr   r   r   r   r   r   r   r   r   r   r    c                    ||          }	 t          j        | j        | j        |                                          }n'# t
          $ r}t          j        |          |d}~ww xY w|t          u rdn|	                    |          }t          j        | j        t          j        | j        d          || j                  |d<   |S )zThis method is used to get the Pydantic core schema of the class.

        Args:
            source_type: Source type.
            handler: Core schema handler.

        Returns:
            The generated core schema of the class.
        Nwrapr#   r'   )r   r(   r   r   r)   r*   r   r+   r   r,   r   #wrap_serializer_function_ser_schemar.   r   r/   s          r3   r4   z+WrapSerializer.__get_pydantic_core_schema__K   s     %%	H%>	4+W-I-I-K-K KK  	H 	H 	H-=a@@aG	H +/@ @ @gF]F]^iFjFj"-"QY =diPP'n	#
 #
 #
 r5   Nr6   r7   r=   r>   r3   r@   r@   ;   sd           -,,,(K((((NVIVVVV     r>   r@   r   _PartialClsOrStaticMethod_PlainSerializeMethodType)bound_WrapSerializeMethodType.)r   r   check_fields__fieldstrfieldsr   r   r   r   rH   bool | Noner   @Callable[[_PlainSerializeMethodType], _PlainSerializeMethodType]c                   d S Nr=   )rI   r   r   rH   rK   s        r3   field_serializerrP   n   s	     Cr>   modeLiteral['plain']c                   d S rO   r=   rI   rQ   r   r   rH   rK   s         r3   rP   rP   y   	     Cr>   Literal['wrap']>Callable[[_WrapSerializeMethodType], _WrapSerializeMethodType]c                   d S rO   r=   rT   s         r3   rP   rP      rU   r>   r"   r   )rQ   r   r   rH   Literal['plain', 'wrap']Callable[[Any], Any]c                $     d fd}|S )a{  Decorator that enables custom field serialization.

    See [Custom serializers](../concepts/serialization.md#custom-serializers) for more information.

    Four signatures are supported:

    - `(self, value: Any, info: FieldSerializationInfo)`
    - `(self, value: Any, nxt: SerializerFunctionWrapHandler, info: FieldSerializationInfo)`
    - `(value: Any, info: SerializationInfo)`
    - `(value: Any, nxt: SerializerFunctionWrapHandler, info: SerializationInfo)`

    Args:
        fields: Which field(s) the method should be called on.
        mode: The serialization mode.

            - `plain` means the function will be called instead of the default serialization logic,
            - `wrap` means the function will be called with an argument to optionally call the
               default serialization logic.
        return_type: Optional return type for the function, if omitted it will be inferred from the type annotation.
        when_used: Determines the serializer will be used for serialization.
        check_fields: Whether to check that the fields actually exist on the model.

    Returns:
        The decorator function.
    fHCallable[..., Any] | staticmethod[Any, Any] | classmethod[Any, Any, Any]r   (_decorators.PydanticDescriptorProxy[Any]c                `    t          j                  }t          j        | |          S )N)rK   rQ   r   r   rH   )r   FieldSerializerDecoratorInfoPydanticDescriptorProxy)r\   dec_inforH   rK   rQ   r   r   s     r3   deczfield_serializer.<locals>.dec   s@     ;#%
 
 
 21h???r>   )r\   r]   r   r^   r=   )rQ   r   r   rH   rK   rc   s   ````` r3   rP   rP      sK    B
@ 
@ 
@ 
@ 
@ 
@ 
@ 
@ 
@ 
@ Jr>   FuncType__fc                    d S rO   r=   )re   s    r3   model_serializerrg      s    Cr>   rQ   r   r   Callable[[FuncType], FuncType]c                    d S rO   r=   rh   s      r3   rg   rg      s	     Cr>   Callable[..., Any] | Nonec               6    dfd}| |S  ||           S )a  Decorator that enables custom model serialization.

    See [Custom serializers](../concepts/serialization.md#custom-serializers) for more information.

    Args:
        __f: The function to be decorated.
        mode: The serialization mode.

            - `'plain'` means the function will be called instead of the default serialization logic
            - `'wrap'` means the function will be called with an argument to optionally call the default
                serialization logic.
        when_used: Determines when this serializer should be used.
        return_type: The return type for the function. If omitted it will be inferred from the type annotation.

    Returns:
        The decorator function.
    r\   Callable[..., Any]r   r^   c                \    t          j                  }t          j        | |          S )N)rQ   r   r   )r   ModelSerializerDecoratorInfora   )r\   rb   rQ   r   r   s     r3   rc   zmodel_serializer.<locals>.dec   s/    ;S^jsttt21h???r>   N)r\   rm   r   r^   r=   )re   rQ   r   r   rc   s    ``` r3   rg   rg      sN    2@ @ @ @ @ @ @ @ {
s3xxr>   AnyTypec                  ,    e Zd ZddZdd	Zej        Zd
S )SerializeAsAnyitemr   r   c                8    t           |t                      f         S rO   )r   rr   )clsrs   s     r3   __class_getitem__z SerializeAsAny.__class_getitem__  s    T>#3#3344r>   r   r   r   r    c                     ||          }|}|d         dk    r(|                                 }|d         }|d         dk    (t          j        d t          j                              |d<   |S )Ntypedefinitionsr1   c                     ||           S rO   r=   )xhs     r3   <lambda>z=SerializeAsAny.__get_pydantic_core_schema__.<locals>.<lambda>  s    QQqTT r>   )r1   r'   )copyr   rC   
any_schema)r0   r   r   r1   schema_to_updates        r3   r4   z+SerializeAsAny.__get_pydantic_core_schema__  s     W[))F%"6*m;;#3#8#8#:#: #3H#=  #6*m;; 1<0_!!+*@*B*B1 1 1_- Mr>   N)rs   r   r   r   r6   )r8   r9   r:   rv   r4   object__hash__r=   r>   r3   rr   rr     s?        	5 	5 	5 	5	 	 	 	 ?r>   rr   r=   )rI   rJ   rK   rJ   r   r   r   r   rH   rL   r   rM   )rI   rJ   rK   rJ   rQ   rR   r   r   r   r   rH   rL   r   rM   )rI   rJ   rK   rJ   rQ   rV   r   r   r   r   rH   rL   r   rW   )rK   rJ   rQ   rY   r   r   r   r   rH   rL   r   rZ   )re   rd   r   rd   )rQ   rY   r   r   r   r   r   ri   rO   )
re   rk   rQ   rY   r   r   r   r   r   rZ   )/r;   
__future__r   dataclasses	functoolsr   typingr   r   r   r   r	   r
   pydantic_corer   r   _core_schematyping_extensionsr   r   r    r   	_internalr   r   annotated_handlersr   	dataclass
slots_truer   r@   classmethodstaticmethodrD   r<   SerializerFunction_PlainSerializationFunctionWrapSerializerFunction_WrapSerializationFunctionrE   rG   rP   rd   rg   rp   rr   r=   r>   r3   <module>r      s>   K K K " " " " " "     # # # # # # I I I I I I I I I I I I I I I I 8 8 8 8 8 8 8 8 5 5 5 5 5 5 ; ; ; ; ; ; ; ; ; ; ) ) ) ) ) ) 7 7 7 7 7 7 7 7 4 4 4 4 4 4 EE,7EEEEE& & & & & & & FE&R EE,7EEEEE' ' ' ' ' ' ' FE'T  e+0S#s]1K\Z]_bZbMcersvew1w+xxxxx"'(GIb(b"c!&|'JLe'e!f '(CKf g g g&w'AIcddd 
 NQ #     
 

 NQ #     
 

 NQ #     
 &-(NV $- - - - - -` 7:Xc3h%7888 
   
 
 &)NV	     
 &*  &-NV(           F ')

  #w|,N  [<<0;<<# # # # # # # =<# # #r>   