
    h!                        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d eD             d eD             z   Z d Z!eeefZ"	 	 ddZ#e#j$        ej$        ej$        ej$        ej$        ej$        ej$        fZ%[[[[[[[	dS )    )MappingProxyType)array
frozendict)MutableMappingMutableSequence
MutableSet)Enumc                     ddl m} t          | |j                  o&t          | t                     ot          | d           S )Nr   abcisalpha)collectionsr   
isinstanceIterable
memoryviewhasattror   s     M/var/www/html/marketdash/venv/lib/python3.11/site-packages/frozendict/cool.pyisIterableNotStringr      sT     	1cl## 	"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      sY    a&& 64555!S[!! zr   c                     | S N )xs    r   nilr$   %   s    Hr   c                       e Zd ZdS )FreezeErrorN__name__
__module____qualname__r"   r   r   r&   r&   4           Dr   r&   c                       e Zd ZdS )FreezeWarningNr'   r"   r   r   r-   r-   8   r+   r   r-   F)inversec                   t          t          |           t                    st          d|  d          	 |j         n## t          $ r t          d| dz             w xY w|rt                      }nt                      }| |v r'ddl}|                    | j	         dt                     |rt          }nt          }||| <   dS )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_mapr8   s        r   registerr?   <   s    d:&&-- 
HjHHH
 
 	

 
 
 
DDD
 
 	

  9 = ? ? 6 8 8***"EEE	
 	
 	

  > E =(1*%%%s	   ?  Ac                 z    |rt           }nt          }	 || = dS # 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(   )r2   r.   r>   s      r   
unregisterrB   k   sg      > E =@!$''' @ @ @T]>>>???@s    ":c                       t           t          z  S r!   )_freeze_conversion_mapr;   r"   r   r   r7   r7   }   s    !$AAAr   c                       t           t          z  S r!   )_freeze_conversion_inverse_mapr:   r"   r   r   r6   r6      s    &-	.r   c                     g | ]}|S r"   r"   .0r#   s     r   
<listcomp>rJ      s    '''1Q'''r   c                     g | ]}|S r"   r"   rH   s     r   rJ   rJ      s    ///1Q///r   c                  r    t          t          d t          D             z   d t          D             z             S )Nc                     g | ]}|S r"   r"   rH   s     r   rJ   z"getFreezeTypes.<locals>.<listcomp>   s    222q222r   c                     g | ]}|S r"   r"   rH   s     r   rJ   z"getFreezeTypes.<locals>.<listcomp>   s    :::q:::r   )tuple_freeze_typesr;   r:   r"   r   r   getFreezeTypesrQ      sE    221222	3::9:::	;  r   Nc                    ddl m } |
 |            }|
 |            }|                                D ]h\  }}t          t          |          t                    st	          | ddz             	 |j         E# t          $ r t	          d| ddz             w xY w|                                D ]h\  }}t          t          |          t                    st	          | d	d
z             	 |j         E# t          $ r t	          d| ddz             w xY wt          |           }t          |                                          t                      z   }d}|D ]}	t          | |	          r|	} n|	 | j          || j                  S # t          $ r Y nw xY w	 t          |            | S # t          $ r Y nw xY wd                    d |D                       }
d| dd|
 z   }t          |          t                      }||z  }|t           v r ||         |           S t#          |           s ||         |           S t%                      }||z  }||v }|r ||         |           } ddlm}  ||           } t)          |          |          D ]\  }}t+          |||          ||<   	 ||         }n# t,          $ r	 |r|}n Y nw xY w ||          S )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 r2   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   $   K   | ]}|j         V  d S r!   )r(   rH   s     r   	<genexpr>zdeepfreeze.<locals>.<genexpr>  s$      $F$FAQZ$F$F$F$F$F$Fr   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   r1   r2   r3   r4   r5   rO   keysrQ   r   __dict__hashr   joinr7   _freeze_types_plainr   r6   rU   r   
deepfreezerA   )r   rV   rW   r   type_ir=   type_ofreeze_typesbase_type_ofreeze_typesupported_typeserrr>   freeze_conversion_inverse_mapfrozen_typerU   o_copykvfreezes                       r   r]   r]      sF   8 &%%%%% &JLL ($.JLL!.4466  	$v,,-- 	FFF  
	 	 	 	AAAA-.  	 7<<>>  	$v,,-- 	EEE   
	 	 	 	....HI  	 !WWF*//1122^5E5EELK#  a%% 	%KE	 	*JJ :aj)))  	 	 	D	
	GGG H  	 	 	D	 ))$F$F$F$F$FGG CFBBBAAAB 	
 nn24414EE)))1$[1!444q!! 51$[1!444$A$C$C! 	&!	" "
 !>>K :6)+6q99T!WWF   (( 
 
1 1(A
 
 
q		&{3    	FF F 6&>>sN   0A88!B-C55!D6F 
FFF/ /
F<;F<5J> >KK)F)NN)&typesr   r   r   collections.abcr   r   r	   enumr
   r1   r?   r   r   r$   	bytearraybytesrO   	frozensetrD   r;   	Exceptionr&   UserWarningr-   rB   r7   r   listrF   r:   r6   rP   rQ   r\   r]   r(   __all__r"   r   r   <module>ru      s   " " " " " "       ! ! ! ! ! ! G G G G G G G G G G      
 z%)) $OU###  	 	 	   $JuU	#%    !# 	 	 	 	 	) 	 	 		 	 	 	 	K 	 	 	 27 ,2 ,2 ,2 ,2 ,2^@ @ @ @$B B B ",d	4- " "  )+ %   ('&'''//.///0    "9e4 
 !$(R R R Rl #!* 	DDr   