L i/ZdZddlmZddlmZmZerddlmZd dZ d d dZ d dZ y) zTools for working with dicts.) annotations) TYPE_CHECKINGAny)Mappingci}|jD]9\}}|jd}d}|}|D]}||vri||<|}||}|5||<;|S)aConvert a flat dict of key-value pairs to dict tree. Example ------- _unflatten_single_dict({ foo_bar_baz: 123, foo_bar_biz: 456, x_bonks: 'hi', }) # Returns: # { # foo: { # bar: { # baz: 123, # biz: 456, # }, # }, # x: { # bonks: 'hi' # } # } Parameters ---------- flat_dict : dict A one-level dict where keys are fully-qualified paths separated by underscores. Returns ------- dict A tree made of dicts inside of dicts. _N)itemssplit) flat_dictoutpathstrvpath prev_dict curr_dictks f/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/streamlit/elements/lib/dicttools.py_unflatten_single_dictrsJCoo'  }}S!+/   %A !! ! !I!! I  %  IaL  JNc|| t}t|}t|jD]\}}t |t r t ||}n?t|dr3t|D]%\}}t |t st ||||<'||vsgd|vri|d<||d|<|j||S)a!Converts a flat dict of key-value pairs to a spec tree. Example ------- unflatten({ foo_bar_baz: 123, foo_bar_biz: 456, x_bonks: 'hi', }, ['x']) # Returns: # { # foo: { # bar: { # baz: 123, # biz: 456, # }, # }, # encoding: { # This gets added automatically # x: { # bonks: 'hi' # } # } # } Args ---- flat_dict: dict A flat dict where keys are fully-qualified paths separated by underscores. encodings: set Key names that should be automatically moved into the 'encoding' key. Returns ------- A tree made of dicts inside of dicts. __iter__encoding) setrlistr isinstancedict unflattenhasattr enumeratepop)r encodingsout_dictrrichilds rrrQsRE %i0HX^^%&1 a !Y'A Q #%aL 75eT*$UI6AaD 7 >)')$&'HZ  # LLO Orci}|jD](\}}| t|tr t|n|||<*|S)z-Remove all keys with None values from a dict.)r rrremove_none_values) input_dictnew_dictkeyvals rr&r&sLH$$&VS ?7A#t7L.s3RUHSMV Or)r dict[Any, Any]returnr+)N)r r+r!zset[str] | Noner,r+)r'zMapping[Any, Any]r,r+) __doc__ __future__rtypingrrcollections.abcrrrr&rrr2sE$"%'5r=A>>*9>>Br