XBFj vdZddlmZddlZddlZddlZddlmZddlm Z ddl m Z dd Z Gd de Z dS)z6Manager to read and modify config data in JSON files. ) annotationsN)Any)LoggingConfigurable)Unicodetargetdict[Any, Any]newreturnNonec|D]c\}}t|tr+||vri||<t|||||s||=E|||d^|||<ddS)z^Recursively update one dictionary using another. None values will delete their keys. N)items isinstancedictrecursive_updatepop)rr kvs FC:\PYTHON\_runtimes\venv\Lib\site-packages\traitlets/config/manager.pyrrs   1 a   q VAY * * *!9 1I Y JJq$    F1II  cPeZdZdZedZddZddZdd Zdd Z ddZ dS)BaseJSONConfigManagerzYGeneral JSON config manager Deals with persisting/storing config in a json file .r r c tj|jddS#t$r!}|jtjkrYd}~dSd}~wwxYw)Ni)osmakedirs config_dirOSErrorerrnoEEXIST)selfes rensure_config_dir_existsz.BaseJSONConfigManager.ensure_config_dir_exists-sf  K / / / / /   w%,&&'&&&&& s A AA  section_namestrcRtj|j|dzS)Nz.json)rpathjoinr)r r#s r file_namezBaseJSONConfigManager.file_name4sw||DO\G-CDDDrrc||}tj|r?t |d5}t j|cdddS#1swxYwYdSiS)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)r r#filenamefs rgetzBaseJSONConfigManager.get7s >>,// 7>>( # # h111 $Qy|| $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $IsA''A+.A+datac||}|t|dd5}tj||dddddS#1swxYwYdS)zStore the given config data.wr*r+)indentN)r(r"r.r/dump)r r#r4r1r2s rsetzBaseJSONConfigManager.setDs>>,// %%''' (C' 2 2 2 )a IdAa ( ( ( ( ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )sA!!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. )r3rr:)r r#r;r4s rupdatezBaseJSONConfigManager.updateLs> xx %%x((( t$$$ rN)r r )r#r$r r$)r#r$r r)r#r$r4rr r )r#r$r;rr r) __name__ __module__ __qualname____doc__rrr"r(r3r:r=rrrr%s JEEEE    ))))rr)rrr rr r )rA __future__rrr/rtypingrtraitlets.configrtraitlets.traitletsrrrrBrrrGs#""""" 000000''''''*///////////r