MCPcopy Create free account
hub / github.com/cdgriffith/Box / _get_dot_paths

Function _get_dot_paths

box/box.py:203–222  ·  view source on GitHub ↗

A generator of all the end node keys in a box in box_dots format

(bx, current="")

Source from the content-addressed store, hash-verified

201
202
203def _get_dot_paths(bx, current=""):
204 """A generator of all the end node keys in a box in box_dots format"""
205
206 def handle_dicts(sub_bx, paths=""):
207 for key, value in sub_bx.items():
208 yield f"{paths}.{key}" if paths else key
209 if isinstance(value, dict):
210 yield from handle_dicts(value, f"{paths}.{key}" if paths else key)
211 elif isinstance(value, list):
212 yield from handle_lists(value, f"{paths}.{key}" if paths else key)
213
214 def handle_lists(bx_list, paths=""):
215 for i, value in enumerate(bx_list):
216 yield f"{paths}[{i}]"
217 if isinstance(value, list):
218 yield from handle_lists(value, f"{paths}[{i}]")
219 if isinstance(value, dict):
220 yield from handle_dicts(value, f"{paths}[{i}]")
221
222 yield from handle_dicts(bx, current)
223
224
225def _get_box_config():

Callers 1

Calls 1

handle_dictsFunction · 0.85

Tested by 1