o
    "“i
  ã                	   @   sh   d Z ddlmZ ddlmZmZmZmZ ddlm	Z	 edƒZ
		dde	d	ee d
ee ddfdd„ZdS )z:Strategy for using class-specific (un)structuring methods.é    )Ú	signature)ÚAnyÚCallableÚOptionalÚTypeVaré   )ÚBaseConverterÚTNÚ	converterÚstructure_method_nameÚunstructure_method_nameÚreturnc                    sŠ   ˆr"dt t dttt t gtf f‡ ‡fdd„}ˆ  ‡fdd„|¡ ˆrCdt t dttgtf f‡ ‡fdd„}ˆ  ‡fd	d„|¡ d
S d
S )aê  
    Configure the converter such that dedicated methods are used for (un)structuring
    the instance of a class if such methods are available. The default (un)structuring
    will be applied if such an (un)structuring methods cannot be found.

    :param converter: The `Converter` on which this strategy is applied. You can use
        :class:`cattrs.BaseConverter` or any other derived class.
    :param structure_method_name: Optional string with the name of the class method
        which should be used for structuring. If not provided, no class method will be
        used for structuring.
    :param unstructure_method_name: Optional string with the name of the class method
        which should be used for unstructuring. If not provided, no class method will
        be used for unstructuring.

    If you want to (un)structured nested objects, just append a converter parameter
    to your (un)structuring methods and you will receive the converter there.

    .. versionadded:: 23.2.0
    Úclr   c                    sJ   t | ˆƒ‰ ttˆ ƒjƒ}|dkr‡ fdd„S |dkr!‡‡ fdd„S tdƒ‚)Né   c                    s   ˆ | ƒS ©N© ©ÚvÚ_©Úfnr   ú`/var/www/html/premium_crap/venv/lib/python3.10/site-packages/cattrs/strategies/_class_methods.pyÚ<lambda>*   s    zHuse_class_methods.<locals>.make_class_method_structure.<locals>.<lambda>r   c                    ó
   ˆ| ˆ ƒS r   r   r   ©r
   r   r   r   r   ,   ó   
 z1Provide a class method with one or two arguments.©ÚgetattrÚlenr   Ú
parametersÚ	TypeError©r   Ún_parameters)r
   r   r   r   Úmake_class_method_structure&   s   
z6use_class_methods.<locals>.make_class_method_structurec                    ó
   t | ˆ ƒS r   ©Úhasattr©Út)r   r   r   r   0   r   z#use_class_methods.<locals>.<lambda>c                    sB   t | ˆƒ‰ ttˆ ƒjƒ}|dkrˆ S |dkr‡‡ fdd„S tdƒ‚)Nr   r   c                    r   r   r   )Úself_r   r   r   r   ;   r   zJuse_class_methods.<locals>.make_class_method_unstructure.<locals>.<lambda>z)Provide a method with no or one argument.r   r!   )r
   r   r   r   Úmake_class_method_unstructure5   s   
z8use_class_methods.<locals>.make_class_method_unstructurec                    r$   r   r%   r'   )r   r   r   r   ?   r   N)Útyper	   r   r   Úregister_structure_hook_factoryÚ!register_unstructure_hook_factory)r
   r   r   r#   r*   r   )r
   r   r   r   Úuse_class_methods   s   ,	ÿ&	ÿõr.   )NN)Ú__doc__Úinspectr   Útypingr   r   r   r   Ú r   r	   Ústrr.   r   r   r   r   Ú<module>   s     ýÿþýü