K i ndZddlmZddlZddlZddlZddlmZddlm Z ddl m Z d dZ Gdd e Z y) z6Manager to read and modify config data in JSON files. ) annotationsN)Any)LoggingConfigurable)Unicodec|jD]Q\}}t|tr"||vri||<t|||||r4||=8||j |dM|||<Sy)z^Recursively update one dictionary using another. None values will delete their keys. N)items isinstancedictrecursive_updatepop)targetnewkvs ^/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/traitlets/config/manager.pyr r sq  1 a q VAY *!91I Y JJq$ F1I cHeZdZdZedZd dZd dZd dZd dZ d dZ y)BaseJSONConfigManagerzYGeneral JSON config manager Deals with persisting/storing config in a json file .c tj|jdy#t$r(}|jtj k7rYd}~yd}~wwxYw)Ni)osmakedirs config_dirOSErrorerrnoEEXIST)selfes rensure_config_dir_existsz.BaseJSONConfigManager.ensure_config_dir_exists-sA  KK / ww%,,&' s # AAAc\tjj|j|dzS)Nz.json)rpathjoinr)r section_names r file_namezBaseJSONConfigManager.file_name4s ww||DOO\G-CDDrc|j|}tjj|r,t |d5}t j |cdddSiS#1swYyxYw)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-8encodingN)r$rr!isfileopenjsonload)rr#filenamefs rgetzBaseJSONConfigManager.get7sZ >>,/ 77>>( #h1 $Qyy| $ $I $ $s AA(c|j|}|jt|dd5}tj||ddddy#1swYyxYw)zStore the given config data.wr&r')indentN)r$rr*r+dump)rr#datar-r.s rsetzBaseJSONConfigManager.setDsO>>,/ %%' (C' 2 )a IIdAa ( ) ) )s AAcd|j|}t|||j|||S)zModify the config section by recursively updating it with new_data. Returns the modified config data as a dictionary. )r/r r6)rr#new_datar5s rupdatezBaseJSONConfigManager.updateLs/ xx %x( t$ rN)returnNone)r#strr:r<)r#r<r:r)r#r<r5rr:r;)r#r<r8rr:r) __name__ __module__ __qualname____doc__rrrr$r/r6r9rrrr%s, JE )rr)r dict[Any, Any]rrBr:r;)r@ __future__rrr+rtypingrtraitlets.configrtraitlets.traitletsrr rrArrrGs3# 0'*///r