o
    "it                     @  s\  U d dl mZ d dlZd dlmZmZmZ d dlmZm	Z	m
Z
mZ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mZmZmZ dd	l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+ ddl,m-Z-m.Z.m/Z/ ddlm0Z0 ddl1m2Z2 ddl3m4Z4 erddl5m6Z6 g dZ7					d]d^d d!Z8ed"Z9i d#d$d%d#fd_d6d7Z:	#	$	%	#d`dad8d9Z;i d%d$d%d%d%d#fdbd>d?Z<	%	$	%	%	%	#dcddd@dAZ=eee	 ge	f Z>ee?e	dBf ge	f Z@dCeAdD< 		dedfdIdJZBeee	e	f ge	f ZC		dedgdNdOZDeDZEdPeAdQ< eFeed%fdhdVdWZGeGZHdPeAdX< 	didjdZd[ZIeIZJdPeAd\< dS )k    )annotationsN)CallableIterableMapping)TYPE_CHECKINGAnyFinalLiteralTypeVar)NOTHING	AttributeFactory)	NoDefault   )	ANIES	TypeAliasadapted_fieldsget_args
get_originis_annotatedis_bareis_bare_final
is_generic)deep_copy_with)UnstructureHook)AttributeValidationNoteClassValidationErrorForbiddenExtraKeysErrorIterableValidationErrorIterableValidationNoteStructureHandlerNotFoundError)identity)SimpleStructureHook   )AttributeOverridealready_generatingneutral)generate_mapping)generate_unique_filename)find_structure_handler)BaseConverter)make_dict_structure_fn!make_dict_structure_fn_from_attrsmake_dict_unstructure_fn#make_dict_unstructure_fn_from_attrs make_hetero_tuple_unstructure_fnmake_iterable_unstructure_fnmake_mapping_structure_fnmake_mapping_unstructure_fnomit_if_defaultbool | Nonerename
str | Noneomitstruct_hook Callable[[Any, Any], Any] | Noneunstruct_hookCallable[[Any], Any] | Nonereturnr$   c                 C  s   t | ||||S )zOverride how a particular field is handled.

    :param omit: Whether to skip the field or not. `None` means apply default handling.
    )r$   )r3   r5   r7   r8   r:    r=   S/var/www/html/premium_crap/venv/lib/python3.10/site-packages/cattrs/gen/__init__.pyoverride5   s   r?   TFTfrom_converterattrslist[Attribute]cltype[T]	converterr*   typevar_mapdict[str, Any]_cattrs_omit_if_defaultbool_cattrs_use_linecache_cattrs_use_alias bool | Literal['from_converter']_cattrs_include_init_falsekwargsCallable[[T], dict[str, Any]]c               	   K  sX  d|j  }	i }
g }g }i }|dkrt|dd}| D ]2}|j}||t}|jr)q|jdu r4|js4|s4q|jdu rA|s=|n|j}n|j}|j	}d}|j
durR|j
}n_|jdur|j}t|trn|j |v rj||j  }n|j}nt|rt|st|st|||}|du rt|r|j	turt|j	ts|j	j}z	|j|dd}W n ty   |j}Y nw n|j}|tk}|sd| }||
|< |||< | d| d	}nd
| }|tur@|r|jdus|jr@d| }t|tr |j|
|< |j||< |jr|d| d| d n|d| d| d |d| d|  q||
|< |||< |d| d| d |d| d|  q|d| d| d qddd |D }|r_d| }| D ]	\}}||
|< qcd|	 d| dgdg dd |D  dg | dg }d |}t |d!|r|ng d"}t!t"||d#|
 |
|	 }||_#|S )$a  
    Generate a specialized dict unstructuring function for a list of attributes.

    Usually used as a building block by more specialized hook factories.

    Any provided overrides are attached to the generated function under the
    `overrides` attribute.

    :param cl: The class for which the function is generated; used mostly for its name,
        module name and qualname.
    :param _cattrs_omit_if_default: if true, attributes equal to their default values
        will be omitted in the result dictionary.
    :param _cattrs_use_alias: If true, the attribute alias will be used as the
        dictionary key by default.
    :param _cattrs_include_init_false: If true, _attrs_ fields marked as `init=False`
        will be included.

    ..  versionadded:: 24.1.0
    ..  versionchanged:: 25.2.0
        The `_cattrs_use_alias` parameter takes its value from the given converter
        by default.
    unstructure_rA   	use_aliasFNcache_result
__c_unstr_z
(instance.)	instance.__c_def_z  if instance.z != z(instance):z():	    res[''] = :'z': ,, c                 S     g | ]	}| d | qS =r=   .0ir=   r=   r>   
<listcomp>       z7make_dict_unstructure_fn_from_attrs.<locals>.<listcomp>def z	(instance):	  res = {c                 S     g | ]}d | qS z    r=   rc   liner=   r=   r>   re          z  }  return res
unstructurelinesexec)$__name__getattrnamegetr&   r7   initr5   aliasdefaultr:   type
isinstancer
   rq   r   r   r   r   r   r   r   	__class__get_unstructure_hookRecursionErrorr!   r3   factory
takes_selfappendjoinitemsr(   evalcompile	overrides) rB   rD   rF   rG   rI   rK   rL   rN   rO   fn_nameglobsrs   invocation_linesinternal_arg_partsa	attr_namer?   kndhandlertis_identityunstruct_handler_nameinvokedef_nameinternal_arg_linekvtotal_linesscriptfnameresr=   r=   r>   r.   F   s   
"

















r.   c              	   K  s   t | }t|p| }i }	|dkrt|dd}t| r%t| |	}	|dur%|} ztj}
W n ty9   t }
|
t_Y nw | |
v rAt	 |

|  zt|| ||	f||||d|W |
|  |
sat`S S |
|  |
skt`w )a+  
    Generate a specialized dict unstructuring function for an attrs class or a
    dataclass.

    Any provided overrides are attached to the generated function under the
    `overrides` attribute.

    :param _cattrs_omit_if_default: if true, attributes equal to their default values
        will be omitted in the result dictionary.
    :param _cattrs_use_alias: If true, the attribute alias will be used as the
        dictionary key by default.
    :param _cattrs_include_init_false: If true, _attrs_ fields marked as `init=False`
        will be included.

    ..  versionadded:: 23.2.0 *_cattrs_use_alias*
    ..  versionadded:: 23.2.0 *_cattrs_include_init_false*
    ..  versionchanged:: 25.2.0
        The `_cattrs_use_alias` parameter takes its value from the given converter
        by default.
    rA   rR   FN)rI   rK   rL   rN   )r   r   rv   r   r'   r%   working_setAttributeErrorsetr   addr.   remove)rD   rF   rI   rK   rL   rN   rO   originrB   mappingr   r=   r=   r>   r-      sN   



	

r-   _cattrs_forbid_extra_keys _cattrs_prefer_attrib_converters_cattrs_detailed_validation)SimpleStructureHook[Mapping[str, Any], T]c
           ,      K  s
  |j }d| }t|ddD ]=}z||j  }W n ty*   |j }td| d|dw t|ddp4t|}tdd	|}td
d|}|d	| 7 }qd|i}i }g }g }g }g }t }|dkrft|dd}|dkrpt|dd}|dkrw|j}|dkr~|j	}|r||d< t
|d< |r|d |d |d t|d< t|d< | D ]}|j}|
|t}|jrq|jdu r|js|	sq|j}t|tr||j |}nt|rt|st|st|||}|jdur|j}nt||||}d| }|dur|||< |j}|jdu r|s|n|j}n|j}|| d} |js|jt ur4||  d| d |  d} ||  d |  d} d| }!|||!< |dur||j!krk|||< ||  d| d| d | d! n,d| }"|||"< ||  d| d| d | d"|" d#
 n||  d| d$| d% | dd& } ||  d' |  d} ||  d(|j" d)| d*| d+| d,
 ||  d- q|jt ur||  d| d |  d} ||  d |  d} d| }!|||!< |r(||j!kr|||< ||  d.| d/| d | d! n#||  d.| d/| d | d"|! d#
 n||  d.| d0| d% | dd& } ||  d' |  d} ||  d(|j" d)| d*| d+| d,
 ||  d- q|rp|g d17 }|d2|d3 |sd4gd5g d6d7 |D  d8g d9|d:g }#nd4gd;g d<d7 |D  d8g d9|d:g }#|d= nhg }$| D ]}|j}|
|t}|jrɐq|jdu r|js|	sؐq|jt ur|$| q|j}t|tr||j |}nt|rt|st|st|||}|jdur|j}nt||||}|jdu r+|s'|n|j}n|j}|| |js|durud| }|||< ||j!kr\|||< d>| d| d | d!}%n"d| }"|||"< d>| d| d | d"|" d#	}%n	d>| d$| d%}%||% q|rd| }|||< ||j!kr|||< | d | d?}&nd| }"|||"< | d | d"|" d@}&ndA| dB}&|j#r|j dC|& }&||& q|$r|d |d |$D ]}|j}|
|t}|j}t|tr||j |}nt|rt|st|st|||}|jdur|j}nt||||}d| }|||< |jdu r<|s8|n|j}n|j}|| |js|dD| d |r||j!kro|||< |dE| d| d | d! qd| }"|||"< |dE| d| d | d"|" d#	 q|dE| d$| d% q|dD| d |r||j!kr|||< |dF|j d/| d | d! qd| }"|||"< |dF|j d/| d | d"|" d#	 q|dF|j d0| d% q|s dGgdHd7 |D  dIg }#ndJgdKd7 |D  dIg }#|d= |r|g dL7 }dM$dNd7 |D }'|%| dO| dP|' dQg|||#|}(dR$|(})t&|dS|rI|(ng dT}*t't(|)|*dU| || }+|
|+_)|+S )Va  
    Generate a specialized dict structuring function for a list of attributes.

    Usually used as a building block by more specialized hook factories.

    Any provided overrides are attached to the generated function under the
    `overrides` attribute.

    :param _cattrs_forbid_extra_keys: Whether the structuring function should raise a
        `ForbiddenExtraKeysError` if unknown keys are encountered.
    :param _cattrs_use_linecache: Whether to store the source code in the Python
        linecache.
    :param _cattrs_prefer_attrib_converters: If an _attrs_ converter is present on a
        field, use it instead of processing the field normally.
    :param _cattrs_detailed_validation: Whether to use a slower mode that produces
        more detailed errors.
    :param _cattrs_use_alias: If true, the attribute alias will be used as the
        dictionary key by default.
    :param _cattrs_include_init_false: If true, _attrs_ fields marked as `init=False`
        will be included.

    ..  versionadded:: 24.1.0
    ..  versionchanged:: 25.2.0
        The `_cattrs_use_alias` parameter takes its value from the given converter
        by default.
    
structure___parameters__r=   z"Missing type for generic argument z, specify it when structuring.Nru   z[\[\.\] ,<>]_z\|u__clrA   forbid_extra_keysFrR   __c_a__c_fekez
  res = {}z  errors = []z**res,__c_cve__c_avn__c_structure_z  zif 'z' in o:ztry:	__c_type_rW   z = z(o['z'])z'], rV   z = o['z']zexcept Exception as e:zHe.__notes__ = getattr(e, '__notes__', []) + [__c_avn("Structuring class z @ attribute z", "z", __c_type_z)]zerrors.append(e)zres['rZ   z'] = o[')(  unknown_fields = set(o.keys()) - __c_a  if unknown_fields:z5    errors.append(__c_feke('', __cl, unknown_fields))z2  if errors: raise __c_cve('While structuring ' + z, errors, __cl)z  try:z    return __cl(c                 S  rj   z      r=   rl   r=   r=   r>   re     rn   z5make_dict_structure_fn_from_attrs.<locals>.<listcomp>    )z@  except Exception as exc: raise __c_cve('While structuring ' + z, [exc], __cl)z    instance = __cl(c                 S  rj   r   r=   rl   r=   r=   r>   re     rn   z  return instancez  instance.z']),z),zo['z'],ra   z  if 'z    instance.rY   z  return __cl(c                 S  rj   rk   r=   rl   r=   r=   r>   re     rn   z  )z  instance = __cl(c                 S  rj   rk   r=   rl   r=   r=   r>   re     rn   )r   r   z,    raise __c_feke('', __cl, unknown_fields)r^   c                 S  r_   r`   r=   rb   r=   r=   r>   re     rf   rg   z(o, _=__cl, rh   rp   	structurerr   rt   )*ru   rv   KeyErrorr    strresubr   detailed_validation_prefer_attrib_convertersr   r   r   r   rw   rx   r&   r7   ry   r|   r}   r
   r   r   r   r   r8   r)   rz   r5   r   r{   r   _structure_call__qualname__kw_onlyr   updater(   r   r   r   ),rB   rD   rF   rG   r   rK   r   r   rL   rN   rO   cl_namer   p	name_basepnrw   r   r   rs   
post_linespi_linesr   allowed_fieldsr   anr?   r   r   struct_handler_nameianr   rd   	type_nametninstantiation_linesnon_requiredpi_lineinvocation_liner   r   r   r   r   r=   r=   r>   r,   &  s8  *













 
"


 
"


	

















r,   c              	   K  s   i }	t | rt| }
t| |	}	|
dur|
} t| ddD ]}
t |
r/t|
ds/t|
|	}	 nqt| }ztj}W n t	yH   t
 }|t_Y nw | |v rPt ||  zt|| ||	f||||||d|W ||  |srt`S S ||  |s|t`w )a  
    Generate a specialized dict structuring function for an attrs class or
    dataclass.

    Any provided overrides are attached to the generated function under the
    `overrides` attribute.

    :param _cattrs_forbid_extra_keys: Whether the structuring function should raise a
        `ForbiddenExtraKeysError` if unknown keys are encountered.
    :param _cattrs_use_linecache: Whether to store the source code in the Python
        linecache.
    :param _cattrs_prefer_attrib_converters: If an _attrs_ converter is present on a
        field, use it instead of processing the field normally.
    :param _cattrs_detailed_validation: Whether to use a slower mode that produces
        more detailed errors.
    :param _cattrs_use_alias: If true, the attribute alias will be used as the
        dictionary key by default.
    :param _cattrs_include_init_false: If true, _attrs_ fields marked as `init=False`
        will be included.

    ..  versionadded:: 23.2.0 *_cattrs_use_alias*
    ..  versionadded:: 23.2.0 *_cattrs_include_init_false*
    ..  versionchanged:: 23.2.0
        The `_cattrs_forbid_extra_keys` and `_cattrs_detailed_validation` parameters
        take their values from the given converter by default.
    ..  versionchanged:: 24.1.0
        The `_cattrs_prefer_attrib_converters` parameter takes its value from the given
        converter by default.
    ..  versionchanged:: 25.2.0
        The `_cattrs_use_alias` parameter takes its value from the given converter
        by default.
    N__orig_bases__r=   ztyping.Generic)r   rK   r   r   rL   rN   )r   r   r'   rv   r   
startswithr   r%   r   r   r   r   r   r,   r   )rD   rF   r   rK   r   r   rL   rN   rO   r   baserB   r   r=   r=   r>   r+     sX   .






r+   .r   HeteroTupleUnstructureFnr   unstructure_to	type_argstuple | Nonec           
        s  d}|du r
t | n|} fdd|D }dd t|D }|tur(|p%| |d< g }|d| d	 |tur=|d
 n|d tt|D ]}|| tkrZ|d| d qH|d| d| d qH|turq|d n|d g |d}	ttd	|	dd| || S )zGenerate a specialized unstructure function for a heterogenous tuple.

    :param type_args: If provided, override the type arguments.
    unstructure_tupleNc                   s   g | ]}  |qS r=   )r   )rc   type_argrF   r=   r>   re   *  rn   z4make_hetero_tuple_unstructure_fn.<locals>.<listcomp>c                 S  s   i | ]
\}}d | |qS )
__cattr_u_r=   )rc   rd   hr=   r=   r>   
<dictcomp>,  s    z4make_hetero_tuple_unstructure_fn.<locals>.<dictcomp>__cattr_seq_clrg   z(tup):z    res = __cattr_seq_cl((z    res = (z        tup[z],z        __cattr_u_z(tup[z]),z    ))r       return resrp    rt   )
r   	enumeratetupler   rangelenr!   r   r   r   )
rD   rF   r   r   r   handlersr   rs   rd   r   r=   r   r>   r/     s*   


r/   key_handler'Callable[[Any, Any | None], Any] | NoneMappingUnstructureFnc                 C  s^  |p|j }|j }d}| }t| dddurHt| }t|dkr#|\}	}
n|t}	}
|p0|j|	dd}|tkr7d}|j|
dd}|tkrDd}t| }||d}|durSdnd	}|dur[d
nd}d| dg}|tu sp|du r|tu r|du rz|du rztS |	d| d| d n|p| |d< |	d| d| d g |d}t
td|dd| || S )zGenerate a specialized unstructure function for a mapping.

    :param unstructure_to: The class to unstructure to; defaults to the
        same class as the mapping being unstructured.
    unstructure_mapping__args__Nr   FrS   )__cattr_k_u__cattr_v_uz__cattr_k_u(k)r   z__cattr_v_u(v)r   rg   z
(mapping):z    return {:  for k, v in mapping.items()}__cattr_mapping_clz    res = __cattr_mapping_cl((r^   z) for k, v in mapping.items())r   rp   r   rt   )rq   rv   r   r   r   r   r!   r   dictr   r   r   r   )rD   rF   r   r   khval_handlerr   r   argskey_argval_argr   k_uv_urs   r=   r=   r>   mapping_unstructure_factoryL  s>   



r   r   r2   structure_tor|   r   )SimpleStructureHook[Mapping[Any, Any], T]c                 C  s  d}|dkr	|j }d|i}g }i }	t| st| }
t|
dkr0|
\}}|tu r)|}|tu r/|}n|tur<|tu r<|
\}n|tu rH|turH|
\}n|
\}t}|tv oT|tv }|s|j|dd}||jkre|}|j|dd}||jkrs|}||d< ||d< ||d	< ||d
< ||krdnd}||krdnd}nd}|r|	d n|rt
|	d< t|	d< |tur|nt|	d< |tur|nt|	d< t|d< |	d |	d |	d |	d|  |	d |	d |	d |	d |	d |	d|  |	d |	d |	d  |	d |	d! |	d"t| d# n|	d$| d%| d& |tur4|	d' d(d)d* |	D }|rFd(| }|	 D ]	\}}|||< qJ| |d+< d,| d-| d.}|g|d/}d0|}tt|d1d2| || S )3z8Generate a specialized structure function for a mapping.structure_mappingrA   r   r   FrS   __cattr_k_t__cattr_v_t__cattr_k_s__cattr_v_sz__cattr_k_s(k, __cattr_k_t)z__cattr_k_s(k)z__cattr_v_s(v, __cattr_v_t)z__cattr_v_s(v)Tz  res = dict(mapping)r   r   val_typekey_typer   z  res = {}; errors = []z  for k, v in mapping.items():z    try:z      value = z    except Exception as e:z      e.__notes__ = getattr(e, '__notes__', []) + [IterableValidationNote(f'Structuring mapping value @ key {k!r}', k, val_type)]z      errors.append(e)z      continuez      key = z      res[key] = valuez      e.__notes__ = getattr(e, '__notes__', []) + [IterableValidationNote(f'Structuring mapping key @ key {k!r}', k, key_type)]z  if errors:z9    raise IterableValidationError('While structuring ' + z, errors, __cattr_mapping_cl)ri   r   r   z  res = __cattr_mapping_cl(res)r^   c                 S  r_   r`   r=   rb   r=   r=   r>   re     rf   z-mapping_structure_factory.<locals>.<listcomp>rD   rg   z(mapping, cl=clrh   ro   rp   r   rt   )r   r   r   r   r   r   r   get_structure_hookr   r   r   r   r   reprr   r   r   r   r   )rD   rF   r   r  r  r   r   r   rs   r   r   key_arg_candval_arg_candis_bare_dictr   r   k_sv_sr   r   r   def_liner   r   r=   r=   r>   mapping_structure_factory  s   	
















r  r1   r   c                 C  sv   |j }t| dddvr0| jd }t|tr!t|dt}|tu r!t}|j|dd}|tkr0|p/| S |p3| |fdd	}|S )
zA hook factory for unstructuring iterables.

    :param unstructure_to: Force unstructuring to this type, if provided.

    ..  versionchanged:: 24.2.0
        `typing.NoDefault` is now correctly handled as `Any`.
    r   N)Nr=   r   __default__FrS   c                   s   | fdd| D S )Nc                 3  s    | ]} |V  qd S Nr=   rb   _hookr=   r>   	<genexpr>)  s    zMiterable_unstructure_factory.<locals>.unstructure_iterable.<locals>.<genexpr>r=   )iterable_seq_clr  r=   r  r>   unstructure_iterable(  s   z:iterable_unstructure_factory.<locals>.unstructure_iterable)	rq   rv   r   r}   r
   r   r   r   r!   )rD   rF   r   r   r   r  r=   r=   r>   iterable_unstructure_factory  s   


r  r0   )NNNNN)r3   r4   r5   r6   r7   r4   r8   r9   r:   r;   r<   r$   )rB   rC   rD   rE   rF   r*   rG   rH   rI   rJ   rK   rJ   rL   rM   rN   rJ   rO   r$   r<   rP   )FTrA   F)rD   rE   rF   r*   rI   rJ   rK   rJ   rL   rM   rN   rJ   rO   r$   r<   rP   )rB   rC   rD   rE   rF   r*   rG   rH   r   rM   rK   rJ   r   rM   r   rM   rL   rM   rN   rJ   rO   r$   r<   r   )rA   TrA   rA   rA   F)rD   rE   rF   r*   r   rM   rK   rJ   r   rM   r   rM   rL   rM   rN   rJ   rO   r$   r<   r   )NN)
rD   r   rF   r*   r   r   r   r   r<   r   )
rD   r   rF   r*   r   r   r   r   r<   r   )
rD   rE   rF   r*   r   r|   r   rM   r<   r   r  )rD   r   rF   r*   r   r   r<   r   )K
__future__r   r   collections.abcr   r   r   typingr   r   r   r	   r
   rB   r   r   r   typing_extensionsr   _compatr   r   r   r   r   r   r   r   r   	_genericsr   dispatchr   errorsr   r   r   r   r   r    fnsr!   typesr"   _constsr$   r%   r&   r'   _lcr(   _sharedr)   
convertersr*   __all__r?   r@   r.   r-   r,   r+   IterableUnstructureFnr   r   __annotations__r/   r   r   r2   r   r  r1   r  r0   r=   r=   r=   r>   <module>   s    ,  L   ]->| 