
    i                     0    S SK Jr  S SKJr   " S S5      rg)    )AnyNode)
ASSERTIONSc                   4    \ rS rSrSr\4S jrS rSS jrSr	g)	DictImporter   u  
Import Tree from dictionary.

Every dictionary is converted to an instance of `nodecls`.
The dictionaries listed in the children attribute are converted
likewise and added as children.

Keyword Args:
    nodecls: class used for nodes.

>>> from anytree.importer import DictImporter
>>> from anytree import RenderTree
>>> importer = DictImporter()
>>> data = {
...     'a': 'root',
...     'children': [{'a': 'sub0',
...                   'children': [{'a': 'sub0A', 'b': 'foo'}, {'a': 'sub0B'}]},
...                  {'a': 'sub1'}]}
>>> root = importer.import_(data)
>>> print(RenderTree(root))
AnyNode(a='root')
├── AnyNode(a='sub0')
│   ├── AnyNode(a='sub0A', b='foo')
│   └── AnyNode(a='sub0B')
└── AnyNode(a='sub1')
c                     Xl         g Nnodecls)selfr   s     J/app/mltbenv/lib/python3.13/site-packages/anytree/importer/dictimporter.py__init__DictImporter.__init__!   s        c                 $    U R                  U5      $ )zImport tree from `data`.)_DictImporter__import)r   datas     r   import_DictImporter.import_$   s    }}T""r   Nc                     [         (       a  [        U[        5      (       d   eSU;  d   e[        U5      nUR                  S/ 5      nU R                  " SSU0UD6nU H  nU R                  XeS9  M     U$ )Nparentchildren)r    )r   
isinstancedictpopr   r   )r   r   r   attrsr   nodechilds          r   __importDictImporter.__import(   st    :dD))))4'''T
99Z,||363U3EMM%M- r   r
   r	   )
__name__
__module____qualname____firstlineno____doc__r   r   r   r   __static_attributes__r   r   r   r   r      s    6  ' #	r   r   N)anytreer   anytree.configr   r   r   r   r   <module>r*      s     %, ,r   