Current File : /home/inlingua/miniconda3/lib/python3.1/site-packages/frozendict/__pycache__/cool.cpython-312.pyc
�

�Gf �
�,�ddlmZddlmZddlmZddlZddlmZmZmZe	ee�seje�d�Zd�Zeeee
eeeeei�ZiZGd�d	e�ZGd
�de�Zdd
�d�Z
dd�Zd�Zeeeeeeei�ZiZd�ZeD�cgc]}|��c}eD�cgc]}|��c}zZd�Zee
efZ 		dd�Z!e!jDe
jDejDejDejDejDejDfZ#[[[ycc}wcc}w)�)�MappingProxyType)�array��
frozendictN)�MutableMapping�MutableSequence�
MutableSetc�~�ddlm}t||j�xr t|t�xr
t|d�S)Nr��abc�isalpha)�collectionsr�
isinstance�Iterable�
memoryview�hasattr��ors  �/lib/python3.12/site-packages/frozendict/cool.py�isIterableNotStringrs>���	�1�c�l�l�#�	"��q�*�%�%�	"��A�y�!�!��c��ddlm}t||j�st	d��t||j
�rtjStS)Nrrzobject must be an iterable)	rrrr�	TypeError�Mapping�dict�items�	enumeraters  r�getItemsrs=����a����&��4�5�5��!�S�[�[�!��z�z���rc��eZdZy)�FreezeErrorN��__name__�
__module__�__qualname__�rrr r .���rr c��eZdZy)�
FreezeWarningNr!r%rrr(r(2r&rr(F)�inversec�V�tt|�t�std|�d���	|j|rt�}n
t
�}||vr'tj|j�d�t�|rt}nt}|||<y#t$rtd|��dz��wxYw)a�
    Adds a `converter` for a type `to_convert`. `converter`
    must be callable. The new converter will be used by `deepfreeze()`
    and has precedence over any previous converter.
    
    If `to_covert` has already a converter, a FreezeWarning is raised.
    
    If `inverse` is True, the conversion is considered from an immutable 
    type to a mutable one. This make it possible to convert mutable
    objects nested in the registered immutable one.
    z'`to_convert` parameter must be a type, z foundz*`converter` parameter must be a callable, �foundz! is already in the conversion mapN)
�
issubclass�type�
ValueError�__call__�AttributeError�getFreezeConversionInverseMap�getFreezeConversionMap�warnings�warnr"r(�%_freeze_conversion_inverse_map_custom�_freeze_conversion_map_custom)�
to_convert�	converterr)�freeze_conversion_maps    r�registerr:6s����d�:�&��-��5�j�\��H�
�	
�
����� =� ?�� 6� 8���*�*��
�
��"�"�#�#D�E��	
�
� E�� =��(1��*�%��-�
��8���D��
�
�	
�
�s�B
�
B(c�t�|rt}nt}	||=y#t$rt|j�d���wxYw)z�
    Unregister a type from custom conversion. If `inverse` is `True`,
    the unregistered conversion is an inverse conversion
    (see `register()`).
    z is not registeredN)r5r6�KeyErrorr r")r-r)r9s   r�
unregisterr=csI��� E�� =��@�!�$�'���@��T�]�]�O�+=�>�?�?�@�s��"7c��ttzS�N)�_freeze_conversion_mapr6r%rrr2r2us��!�$A�A�Arc��ttzSr?)�_freeze_conversion_inverse_mapr5r%rrr1r1�s��&�-�	.�rc��tttD�cgc]}|��c}ztD�cgc]}|��c}z�Scc}wcc}wr?)�tuple�
_freeze_typesr6r5��xs r�getFreezeTypesrH�s>����1�2�q��2�	3�9�:�q��:�	;�
���2��:s�	:
�	?
c���ddlm}|�|�}|�|�}|j�D]<\}}tt|�t�st	|�d�dz��	|j
�>|j�D]<\}}tt|�t�st	|�d	�d
z��	|j
�>t|�}t|j��t�z}d}|D]}	t||	�s�|	}n|�	|j||j�St�}||z}|t vr|||�St#|�s|||�St%�}
|
|z}
||
v}|r|
||�}ddlm}||�}t)|�|�D]\}}t+|||��||<�	||}||�S#t$rt	d|�d�dz��wxYw#t$rt	d|�d�dz��wxYw#t$rYnwxYw	t|�|S#t$rYnwxYwd
jd�|D��}
d|�d�d|
��z}t|��#t,$r	|r|}n�Y��wxYw)a

    Converts the object and all the objects nested in it in its
    immutable counterparts.
    
    The conversion map is in getFreezeConversionMap().
    
    You can register a new conversion using `register()` You can also
    pass a map of custom converters with `custom_converters` and a map
    of custom inverse converters with `custom_inverse_converters`,
    without using `register()`.
    
    By default, if the type is not registered and has a `__dict__`
    attribute, it's converted to the `frozendict` of that `__dict__`.
    
    This function assumes that hashable == immutable (that is not
    always true).
    
    This function uses recursion, with all the limits of recursions in
    Python.
    
    Where is a good old tail call when you need it?
    rrNz+ in `custom_converters` parameter is not a r-zconverter for z in `custom_converters` zparameter is not a callablez* in `custom_inverse_converters` parameter z
is not a typez in  z6`custom_inverse_converters`parameter is not a callablez, c3�4K�|]}|j���y�wr?)r")�.0rGs  r�	<genexpr>zdeepfreeze.<locals>.<genexpr>�s����$F�A�Q�Z�Z�$F�s�ztype z& is not hashable or is not equal or a z!subclass of the supported types: )�copy)�custom_converters�custom_inverse_converters)rrr,r-r.r/r0rD�keysrHr�__dict__�hashr�joinr2�_freeze_types_plainrr1rMr�
deepfreezer<)rrNrOr�type_ir8�type_o�freeze_types�base_type_o�freeze_type�supported_types�errr9�freeze_conversion_inverse_map�frozen_typerM�o_copy�k�v�freezes                    rrUrU�s:��8&�� �&�L�� �(�$.�L�!�.�4�4�6�
���	��$�v�,��-���(�E�F����
�
	����
�7�<�<�>�
���	��$�v�,��-���(�D�E�� ��
�
	����
��!�W�F��*�/�/�1�2�^�5E�E�L��K�#����a��%�%�K���
��	*�
�J�J��a�j�j�)�)�(3�4��1�4E�E���)�)�1�$�[�1�!�4�4��q�!�1�$�[�1�!�4�4�$A�$C�!�	&�!�	"�"�
�!>�>�K��6�)�+�6�q�9���
�!�W�F� ��� ��(�
���1��
� 1�(A�
��q�	�
��&�{�3���&�>���G�	�� ���(@�A�-�.��
�	���	�� ����.�H�I��
�	��(�	��	��
	���G��H���	��	���)�)�$F��$F�G���F�8�A�B�/��/@�A�
B�	�
��n���J����F��
��sN�F>�)G�G<�1I�>G�G9�<	H�H�H�	H%�$H%�I)�(I))F)NN)$�typesrrrr3�collections.abcrrr	r,r:rr�	bytearray�bytesrD�	frozensetr@r6�	Exceptionr �UserWarningr(r=r2r�listrBr5r1rErHrTrUr"�__all__rFs0r�<module>rlso��"��!��G�G�
�%��)��O���U�#��	�$��J�
�u��U��	�	%���!#��	�)�	�	�K�	�27�*2�Z@�$B�",����d�	�4�-�"��)+�%��'�'�1�Q�'�.�/�1�Q�/�0���"�9�e�4��
!�$(�P�h����������#�#�!�*�*����������	���_(��/s�	D�	D