Ë
    :vžj¨  ã                  ó¨   — d Z ddlmZ ddlZddlZddlZddlZddlZddlZ	ddl
mZ ddlmZmZ eee	j"                  f   Zd
d„Zdd„Z G d„ d	e«      Zy)z5Manager to read and modify config data in JSON files.é    )ÚannotationsN)ÚLoggingConfigurable)ÚBoolÚUnicodec                óÌ   — |j                  «       D ]Q  \  }}t        |t        «      r"|| vri | |<   t        | |   |«       | |   rŒ4| |= Œ8|€| j	                  |d«       ŒM|| |<   ŒS y)z^Recursively update one dictionary using another.

    None values will delete their keys.
    N)ÚitemsÚ
isinstanceÚdictÚrecursive_updateÚpop)ÚtargetÚnewÚkÚvs       ún/workspace/moltex-experiments/.pixi/envs/default/lib/python3.12/site-packages/jupyter_server/config_manager.pyr   r      sl   € ð
 —	‘	–‰ˆˆ1Ü�aœÔØ˜‰Ø��q‘	Ü˜V A™Y¨Ô*Ø˜!“9à˜1‘IàˆYØ�J‰J�q˜$Õð ˆF�1ŠIñ ó    c                óÀ   — t        | j                  «       «      D ]B  \  }}||v sŒt        |t        «      rt	        | |   ||   «       | |   rŒ3| |= Œ7|||   k(  sŒ@| |= ŒD y)z?Recursively remove items from dict that are already in defaultsN)Úlistr   r	   r
   Úremove_defaults)ÚdataÚdefaultsÚkeyÚvalues       r   r   r   )   sa   € ô ˜4Ÿ:™:›<Ö(‰
ˆˆUØ�(Š?Ü˜%¤Ô&Ü  S¡	¨8°C©=Ô9Ø˜C“yØ˜S™	Ø˜( 3™-Ó'Ø˜‘Iñ )r   c                  ób   — e Zd ZdZ ed«      Z ed«      Zdd„Zdd„Z	dd„Z
ddd„Zdd„Zdd	„Zy
)ÚBaseJSONConfigManagerz�General JSON config manager

    Deals with persisting/storing config in a json file with optionally
    default values in a {section_name}.d directory.
    Ú.Tc                ó®   — 	 t        j                  | j                  d«       y# t        $ r(}|j                  t        j
                  k7  r‚ Y d}~yd}~ww xY w)z,Will try to create the config_dir directory.ií  N)ÚosÚmakedirsÚ
config_dirÚOSErrorÚerrnoÚEEXIST)ÚselfÚes     r   Úensure_config_dir_existsz.BaseJSONConfigManager.ensure_config_dir_exists@   sA   € ð	Ü�K‰K˜Ÿ™¨Õ/øÜò 	Ø�w‰wœ%Ÿ,™,Ò&Øô 'ûð	ús   ‚ # £	A¬AÁAc                ó\   — t         j                  j                  | j                  |dz   «      S )zPReturns the json filename for the section_name: {config_dir}/{section_name}.jsonz.json©r   ÚpathÚjoinr    ©r$   Úsection_names     r   Ú	file_namezBaseJSONConfigManager.file_nameH   s    € ä�w‰w�|‰|˜DŸO™O¨\¸GÑ-CÓDÐDr   c                ó\   — t         j                  j                  | j                  |dz   «      S )zNReturns the directory name for the section name: {config_dir}/{section_name}.dz.dr(   r+   s     r   Ú	directoryzBaseJSONConfigManager.directoryL   s    € ä�w‰w�|‰|˜DŸO™O¨\¸DÑ-@ÓAÐAr   c                óÖ  — |r| j                  |«      gng }| j                  rPt        j                  j	                  | j                  |«      d«      }t        t        j                  |«      «      |z   }| j                  j                  d|dj	                  |«      «       i }|D ]x  }t        j                  j                  |«      sŒ#t        j                  j                  |«      sŒCt        |d¬«      5 }	 t        |t        j                  |«      «       ddd«       Œz |S # t        j                   j"                  $ r | j                  j%                  d|«       Y ŒGw xY w# 1 sw Y   ŒÅxY w)a  Retrieve the config data for the specified section.

        Returns the data as a dictionary, or an empty dictionary if the file
        doesn't exist.

        When include_root is False, it will not read the root .json file,
        effectively returning the default values.
        z*.jsonz(Paths used for configuration of %s: 
	%sz
	úutf-8©ÚencodingzInvalid JSON in %s, skippingN)r-   Úread_directoryr   r)   r*   r/   ÚsortedÚglobÚlogÚdebugÚisfileÚgetsizeÚopenr   ÚjsonÚloadÚdecoderÚJSONDecodeErrorÚwarning)r$   r,   Úinclude_rootÚpathsÚpatternr   r)   Úfs           r   ÚgetzBaseJSONConfigManager.getP   s  € ñ 3?�—‘ Ó-Ñ.ÀBˆØ×ÒÜ—g‘g—l‘l 4§>¡>°,Ó#?ÀÓJˆGô œ4Ÿ9™9 WÓ-Ó.°Ñ6ˆEØ�‰�‰Ø8ØØ�K‰K˜Óô	
ð
 "$ˆÛˆDÜ�w‰w�~‰~˜dÕ#¬¯©¯©¸Õ(=Ü˜$¨Õ1°QðOÜ(¨¬t¯y©y¸«|Ô<÷ 2Ð1ð ð ˆøô  Ÿ<™<×7Ñ7ò OØŸ™×(Ñ(Ð)GÈÖNðOú÷ 2Ð1ús*   Ã3EÃ5D Ä 9EÅEÅEÅEÅE(	c                ó\  — | j                  |«      }| j                  «        | j                  r4t        j                  |«      }| j                  |d¬«      }t        ||«       t        j                  |d¬«      }t        |dd¬«      5 }|j                  |«       ddd«       y# 1 sw Y   yxY w)	zStore the given config data.F)rA   é   )ÚindentÚwr1   r2   N)r-   r&   r4   ÚcopyÚdeepcopyrE   r   r<   Údumpsr;   Úwrite)r$   r,   r   Úfilenamer   Újson_contentrD   s          r   ÚsetzBaseJSONConfigManager.setq   s‡   € à—>‘> ,Ó/ˆØ×%Ñ%Ô'à×Òä—=‘= Ó&ˆDØ—x‘x ¸5�xÓAˆHÜ˜D (Ô+ô —z‘z $¨qÔ1ˆÜ�(˜C¨'Õ2°aØ�G‰G�LÔ!÷ 3×2Ñ2ús   ÂB"Â"B+c                ód   — | j                  |«      }t        ||«       | j                  ||«       |S )z‡Modify the config section by recursively updating it with new_data.

        Returns the modified config data as a dictionary.
        )rE   r   rP   )r$   r,   Únew_datar   s       r   ÚupdatezBaseJSONConfigManager.update‚   s/   € ð
 �x‰x˜Ó%ˆÜ˜˜xÔ(Ø�‰�˜tÔ$Øˆr   N)ÚreturnÚNone)r,   ÚstrrT   rV   )T)r,   rV   rA   ÚboolrT   údict[str, t.Any])r,   rV   r   út.AnyrT   rU   )r,   rV   rR   rY   rT   rX   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r    r   r4   r&   r-   r/   rE   rP   rS   © r   r   r   r   6   s<   „ ññ ˜“€JÙ˜$“Z€NóóEóBôóB"ô"r   r   )r   ÚStrDictr   r_   rT   rU   )r   r_   r   r_   rT   rU   )r]   Ú
__future__r   rJ   r"   r6   r<   r   ÚtypingÚtÚtraitlets.configr   Útraitlets.traitletsr   r   r
   rV   ÚAnyr_   r   r   r   r^   r   r   Ú<module>rf      sP   ðÙ ;õ #ã Û Û Û Û 	Û å 0ß -à
ˆs�A—E‘EˆzÑ
€óó*
ôTÐ/õ Tr   