o
    Ö"7h$  ã                   @   s,   d dl Z G dd„ deƒZG dd„ deƒZdS )é    Nc                   @   s@   e Zd ZdZdZdZddd„Zdd	„ Zde_d
d„ Z	dd„ Z
dS )ÚFieldaã  The Field class is used to define what attributes will be serialized.

    It maps a property or function on an object to a value in the serialized result.
    Subclass this to make custom fields. For most simple cases, overriding
    Field.to_value() should be enough. For more control, you may override
    Field.as_getter().

    :param str attr_name: The attribute to get on the object. If not supplied,
        the name the current field was assigned to inside the serializer will be used.
    :param bool call: Whether the value should be called after it is retrieved
        from the object. Useful if an object has a method to be serialized.
    :param str label: A label to use as the name of the serialized field
        instead of using the attribute name of the field.
    :param bool required: Whether the field is required. If set to `False`,
        the method Field.to_value() will not be called if the value is `None` or
        an error is raised during its serialization.
    ©Ú	attr_nameÚcallÚlabelÚrequiredFNTc                 C   s   || _ || _|| _|| _d S )Nr   )Úselfr   r   r   r   © r	   úq/var/www/epreuve.sigeris.cm/public_html/epreuve/venv/lib/python3.10/site-packages/django_rest/serializers/base.pyÚ__init__    s   
zField.__init__c                 C   s   |S )a}  Transforms the serialized value. It could be used for cleaning
        and validating the value serialized by the current field. For example,
        to implement an `int` field, the Field.to_value() method will looks like:

            def to_value(self, value):
                return int(value)

        :param value: The value fetched from the object being serialized.
        r	   )r   Úvaluer	   r	   r
   Úto_value&   s   zField.to_valuec                 C   s$   | j }t|tjƒsdS t|ddƒ S )NTÚ_base_implementationF)r   Ú
isinstanceÚtypesÚ
MethodTypeÚgetattr)r   r   r	   r	   r
   Ú_is_to_value_overridden5   s   zField._is_to_value_overriddenc                 C   s   dS )uë  Returns a function that fetches an attribute from an object.

        If `None` is returned, the default getter defined in `Serializer.default_getter`
        will be used instead.

        When a `Serializer` class is defined, each `Field` class will be
        compiled into a getter function using `Ã¦s_geter()` method. During the serialization
        process, each getter will be called with the object being serialized, then,
        the value returned from the getter will be passed through Field.to_value()
        method.

        If a `Field` class has set the `getter_needs_serializer_as_arg` to `True`,
        then the getter returned from the current method will be called with the
        `Serializer` instance as the first argument, and the object being serialized
        as the second.

        :param str serializer_field_name: The name this field was assigned to on the
            serializer.
        :param serializer_cls: The :class:`Serializer` this field is defined in.
        Nr	   )r   Úserializer_field_nameÚserializer_clsr	   r	   r
   Ú	as_getter=   s   zField.as_getter)NFNT)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__Úgetter_needs_serializer_as_argr   r   r   r   r   r	   r	   r	   r
   r      s    
r   c                   @   s   e Zd Zi ZdS )ÚSerializerBaseN)r   r   r   Ú
_field_mapr	   r	   r	   r
   r   V   s    r   )r   Úobjectr   r   r	   r	   r	   r
   Ú<module>   s   P