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

Function _get_dot_paths

box/box.py:111–130  ·  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

109
110
111def _get_dot_paths(bx, current=""):
112 """A generator of all the end node keys in a box in box_dots format"""
113
114 def handle_dicts(sub_bx, paths=""):
115 for key, value in sub_bx.items():
116 yield f"{paths}.{key}" if paths else key
117 if isinstance(value, dict):
118 yield from handle_dicts(value, f"{paths}.{key}" if paths else key)
119 elif isinstance(value, list):
120 yield from handle_lists(value, f"{paths}.{key}" if paths else key)
121
122 def handle_lists(bx_list, paths=""):
123 for i, value in enumerate(bx_list):
124 yield f"{paths}[{i}]"
125 if isinstance(value, list):
126 yield from handle_lists(value, f"{paths}[{i}]")
127 if isinstance(value, dict):
128 yield from handle_dicts(value, f"{paths}[{i}]")
129
130 yield from handle_dicts(bx, current)
131
132
133def _get_box_config():

Callers 2

setdefaultMethod · 0.85

Calls 1

handle_dictsFunction · 0.85

Tested by 1