
    x8'h!                     B   d dl mZ d dlmZ d dlmZ d dlmZmZmZ d dlm	Z	  e
ee      s ej                  e       d Zd Zd Z eeeeeeeeee	ei      Zi Z G d	 d
e      Z G d de      ZdddZddZd Z eeeeeeei      Zi Zd ZeD  cg c]  } |  c} eD  cg c]  } |  c} z   Z d Z!eeefZ"	 	 ddZ#e#jH                  ejH                  ejH                  ejH                  ejH                  ejH                  ejH                  fZ%[[[[[[[	yc c} w c c} w )    )MappingProxyType)array
frozendict)MutableMappingMutableSequence
MutableSet)Enumc                 ~    ddl m} t        | |j                        xr  t        | t               xr t        | d       S )Nr   abcisalpha)collectionsr   
isinstanceIterable
memoryviewhasattror   s     K/var/www/html/trade_iq/venv/lib/python3.12/site-packages/frozendict/cool.pyisIterableNotStringr      s>     	1cll# 	"q*%%	"Ay!!    c                     ddl m} t        | |j                        st	        d      t        | |j
                        rt        j                  S t        S )Nr   r   zobject must be an iterable)	r   r   r   r   	TypeErrorMappingdictitems	enumerater   s     r   getItemsr      s=    a&455!S[[!zzr   c                     | S N xs    r   nilr%   %   s    Hr   c                       e Zd Zy)FreezeErrorN__name__
__module____qualname__r"   r   r   r'   r'   4       r   r'   c                       e Zd Zy)FreezeWarningNr(   r"   r   r   r.   r.   8   r,   r   r.   F)inversec                V   t        t        |       t              st        d|  d      	 |j                   |rt               }n
t               }| |v r'ddl}|j                  | j                   dt               |rt        }nt        }||| <   y# t        $ r t        d| dz         w xY w)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, foundr   Nz! is already in the conversion map)
issubclasstype
ValueError__call__AttributeErrorgetFreezeConversionInverseMapgetFreezeConversionMapwarningswarnr)   r.   %_freeze_conversion_inverse_map_custom_freeze_conversion_map_custom)
to_convert	converterr/   freeze_conversion_mapr9   s        r   registerr@   <   s     d:&-5j\H
 	

  = ? 6 8**""##DE	

  E =(1*%1  
8D
 	

s   B B(c                 t    |rt         }nt        }	 || = y# t        $ r t        | j                   d      w xY w)z
    Unregister a type from custom conversion. If `inverse` is `True`,
    the unregistered conversion is an inverse conversion
    (see `register()`).
    z is not registeredN)r;   r<   KeyErrorr'   r)   )r3   r/   r?   s      r   
unregisterrC   k   sI      E =@!$' @T]]O+=>??@s    "7c                      t         t        z  S r!   )_freeze_conversion_mapr<   r"   r   r   r8   r8   }   s    !$AAAr   c                      t         t        z  S r!   )_freeze_conversion_inverse_mapr;   r"   r   r   r7   r7      s    &-	.r   c                      t        t        t        D  cg c]  } |  c} z   t        D  cg c]  } |  c} z         S c c} w c c} w r!   )tuple_freeze_typesr<   r;   r#   s    r   getFreezeTypesrK      s>    12q2	39:q:	; 2:s   	:
	?
Nc                    ddl m } | |       }| |       }|j                         D ]<  \  }}t        t        |      t              st	        | ddz         	 |j
                   > |j                         D ]<  \  }}t        t        |      t              st	        | d	d
z         	 |j
                   > t        |       }t        |j                               t               z   }d}|D ]  }	t        | |	      s|	} n |	 | j                    || j                        S t               }||z  }|t         v r ||   |       S t#        |       s ||   |       S t%               }||z  }||v }|r ||   |       } ddlm}  ||       } t)        |      |      D ]  \  }}t+        |||      ||<    	 ||   } ||      S # t        $ r t	        d| ddz         w xY w# t        $ r t	        d| ddz         w xY w# t        $ r Y nw xY w	 t        |        | S # t        $ r Y nw xY wdj                  d |D              }
d| dd|
 z   }t        |      # t,        $ r	 |r|}n Y w xY w)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?
    r   r   Nz+ in `custom_converters` parameter is not a r3   zconverter for z in `custom_converters` zparameter is not a callablez* in `custom_inverse_converters` parameter zis not a typez in  z6`custom_inverse_converters`parameter is not a callablez, c              3   4   K   | ]  }|j                     y wr!   )r)   ).0r$   s     r   	<genexpr>zdeepfreeze.<locals>.<genexpr>  s     $FAQZZ$Fs   ztype z& is not hashable or is not equal or a z!subclass of the supported types: )copy)custom_converterscustom_inverse_converters)r   r   r2   r3   r4   r5   r6   rI   keysrK   r   __dict__hashr   joinr8   _freeze_types_plainr   r7   rP   r   
deepfreezerB   )r   rQ   rR   r   type_ir>   type_ofreeze_typesbase_type_ofreeze_typesupported_typeserrr?   freeze_conversion_inverse_mapfrozen_typerP   o_copykvfreezes                       r   rX   rX      s:   8 & &L ($.L!.446 	$v,-(EF 
	 7<<> 	$v,-(DE  
	 !WF*//12^5EELK# a%%K
 	*JJ ajj))( 3414EE))1$[1!44q!1$[1!44$A$C! 	&!	" "
 !>>K6)+6q9!WF  ( 
1 1(A
q	
&{3 &>K  	 (@A-. 	  	 .HI 	,  		
	G H  		 ))$F$FG F8AB//@AB 	
 nJ  F sN   F>)GG< 1I >GG9<	HHH 	H%$H%I)(I))F)NN)&typesr   r   r   collections.abcr   r   r	   enumr
   r2   r@   r   r   r%   	bytearraybytesrI   	frozensetrE   r<   	Exceptionr'   UserWarningr.   rC   r8   r   listrG   r;   r7   rJ   rK   rW   rX   r)   __all__r#   s   0r   <module>rp      s   "  ! G G 
 %)OU#	 $JuU	#%   !# 	) 		K 	 27 ,2^@$B ",d	4- "  )+ % ''1Q'./1Q/0  "9e4 
 !$(Rl ##!** 	k (/s   	D$	D