
    h                     4    d Z  G d de      Z G d de      Zy)z,jannis@itisme.org (Jannis Andrija Schnitzer)c                       e Zd ZdZd Zd Zy)RecursiveDictionaryzRecursiveDictionary provides the methods rec_update and iter_rec_update
    that can be used to update member dictionaries rather than overwriting
    them.c                     	 |j                         }| j                  |       | j                  |j                                y# t        $ r |}Y >w xY w)aH  Recursively update the dictionary with the contents of other and
        third like dict.update() does - but don't overwrite sub-dictionaries.

        Example:
        >>> d = RecursiveDictionary({'foo': {'bar': 42}})
        >>> d.rec_update({'foo': {'baz': 36}})
        >>> d
        {'foo': {'baz': 36, 'bar': 42}}
        N)itemsAttributeErroriter_rec_update)selfotherthirditerators       P/home/dcms/DCMS/lib/python3.12/site-packages/filer/utils/recursive_dictionary.py
rec_updatezRecursiveDictionary.rec_update!   sL    	{{}H 	X&U[[]+  	H	s   A AAc                     |D ]W  \  }}|| v rIt        | |   t              r6t        |t              r&t        | |         | |<   | |   j                  |       S|| |<   Y y )N)
isinstancedictr   r   r   r   keyvalues       r   r   z#RecursiveDictionary.iter_rec_update2   s`    $ 	"LS%d{$s)T*z%/F/S	:S	S	$$U+!S		"    N)__name__
__module____qualname____doc__r   r    r   r   r   r      s    ,""r   r   c                   (     e Zd ZdZ fdZd Z xZS )RecursiveDictionaryWithExcludesz
    Same as RecursiveDictionary, but respects a list of keys that should be excluded from recursion
    and handled like a normal dict.update()
    c                 R    |j                  dd      | _        t        |   |i | y )Nrec_excluded_keysr   )popr   super__init__)r   argskwargs	__class__s      r   r    z(RecursiveDictionaryWithExcludes.__init__B   s)    !',?!D$)&)r   c                     |D ]q  \  }}|| v rct        | |   t              rPt        |t              r@|| j                  vr2t        | |   | j                        | |<   | |   j	                  |       m|| |<   s y )N)r   )r   r   r   r   r   r   s       r   r   z/RecursiveDictionaryWithExcludes.iter_rec_updateF   sy    $ 	"LS%d{$s)T*z%/F$000;DI&*&<&<>S	S	$$U+!S		"r   )r   r   r   r   r    r   __classcell__)r#   s   @r   r   r   =   s    *	"r   r   N)
__author__r   r   r   r   r   r   <module>r'      s&   4 <
"$ "@"&9 "r   