
    Mh	                    v    d Z ddlmZ ddlZddlZddlZddlmZ ddlm	Z	 ddl
mZ ddZ G d de	          ZdS )z6Manager to read and modify config data in JSON files.
    )annotationsN)Any)LoggingConfigurable)Unicodetargetdict[Any, Any]newreturnNonec                    |                                 D ]c\  }}t          |t                    r+|| vri | |<   t          | |         |           | |         s| |= E||                     |d           ^|| |<   ddS )z^Recursively update one dictionary using another.

    None values will delete their keys.
    N)items
isinstancedictrecursive_updatepop)r   r	   kvs       X/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/traitlets/config/manager.pyr   r      s    
 		  1a 	q	VAY***!9 1IYJJq$ F1II     c                  P    e Zd ZdZ ed          ZddZddZdd
ZddZ	ddZ
dS )BaseJSONConfigManagerzYGeneral JSON config manager

    Deals with persisting/storing config in a json file
    .r
   r   c                    	 t          j        | j        d           d S # t          $ r!}|j        t          j        k    r Y d }~d S d }~ww xY w)Ni  )osmakedirs
config_dirOSErrorerrnoEEXIST)selfes     r   ensure_config_dir_existsz.BaseJSONConfigManager.ensure_config_dir_exists-   sf    	K///// 	 	 	w%,&& '&&&&&	s    
A	AA	section_namestrc                R    t           j                            | j        |dz             S )Nz.json)r   pathjoinr   )r    r#   s     r   	file_namezBaseJSONConfigManager.file_name4   s    w||DO\G-CDDDr   r   c                    |                      |          }t          j                            |          r?t	          |d          5 }t          j        |          cddd           S # 1 swxY w Y   dS i S )zRetrieve the config data for the specified section.

        Returns the data as a dictionary, or an empty dictionary if the file
        doesn't exist.
        utf-8encodingN)r(   r   r&   isfileopenjsonload)r    r#   filenamefs       r   getzBaseJSONConfigManager.get7   s     >>,//7>>(## 	h111 $Qy||$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ Is   A''A+.A+datac                    |                      |          }|                                  t          |dd          5 }t          j        ||d           ddd           dS # 1 swxY w Y   dS )zStore the given config data.wr*   r+      )indentN)r(   r"   r.   r/   dump)r    r#   r4   r1   r2   s        r   setzBaseJSONConfigManager.setD   s    >>,//%%'''(C'222 	)aIdAa((((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)s   A!!A%(A%new_datac                |    |                      |          }t          ||           |                     ||           |S )zModify the config section by recursively updating it with new_data.

        Returns the modified config data as a dictionary.
        )r3   r   r:   )r    r#   r;   r4   s       r   updatezBaseJSONConfigManager.updateL   s>    
 xx%%x(((t$$$r   N)r
   r   )r#   r$   r
   r$   )r#   r$   r
   r   )r#   r$   r4   r   r
   r   )r#   r$   r;   r   r
   r   )__name__
__module____qualname____doc__r   r   r"   r(   r3   r:   r=    r   r   r   r   %   s         
 J   E E E E   ) ) ) )     r   r   )r   r   r	   r   r
   r   )rA   
__future__r   r   r/   r   typingr   traitlets.configr   traitlets.traitletsr   r   r   rB   r   r   <module>rG      s     # " " " " "   				       0 0 0 0 0 0 ' ' ' ' ' '   */ / / / // / / / / /r   