
    Kc		                     \    d Z ddlZddlZddlZddlmZ ddlmZ d Z G d de          Z	dS )z6Manager to read and modify config data in JSON files.
    N)LoggingConfigurable)Unicodec                     |                                 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)targetnewkvs       8lib/python3.11/site-packages/traitlets/config/manager.pyr	   r	      s    
 		  1a 	 q	VAY***!9 1I 	JJq$ F1II     c                   F    e Zd ZdZ ed          Zd Zd Zd Zd Z	d Z
dS )	BaseJSONConfigManagerzYGeneral JSON config manager

    Deals with persisting/storing config in a json file
    .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*   sr    	K///// 	 	 	w%,&      	s    
A	AA	c                 R    t           j                            | j        |dz             S )Nz.json)r   pathjoinr   )r   section_names     r   	file_namezBaseJSONConfigManager.file_name1   s    w||DO\G-CDDDr   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.get4   s     >>,//7>>(## 	h111 $Qy||$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ Is   A''A+.A+c                     |                      |          }|                                  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!   datar+   r,   s        r   setzBaseJSONConfigManager.setA   s    >>,//%%'''3111 	) 	)IdAa((((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)s   A##A'*A'c                 |    |                      |          }t          ||           |                     ||           |S )zModify the config section by recursively updating it with new_data.

        Returns the modified config data as a dictionary.
        )r-   r	   r4   )r   r!   new_datar3   s       r   updatezBaseJSONConfigManager.updateJ   s>    
 xx%%x(((t$$$r   N)__name__
__module____qualname____doc__r   r   r   r"   r-   r4   r7    r   r   r   r   "   s{         
 J  E E E  ) ) )    r   r   )
r;   r   r)   r   traitlets.configr   traitlets.traitletsr   r	   r   r<   r   r   <module>r?      s       				 0 0 0 0 0 0 ' ' ' ' ' '  *0 0 0 0 0/ 0 0 0 0 0r   