MCPcopy Create free account
hub / github.com/nodejs/node / CheckNode

Function CheckNode

tools/gyp/pylib/gyp/input.py:188–220  ·  view source on GitHub ↗
(node, keypath)

Source from the content-addressed store, hash-verified

186
187
188def CheckNode(node, keypath):
189 if isinstance(node, ast.Dict):
190 dict = {}
191 for key, value in zip(node.keys, node.values):
192 assert isinstance(key, ast.Str)
193 key = key.s
194 if key in dict:
195 raise GypError(
196 "Key '"
197 + key
198 + "' repeated at level "
199 + repr(len(keypath) + 1)
200 + " with key path '"
201 + ".".join(keypath)
202 + "'"
203 )
204 kp = list(keypath) # Make a copy of the list for descending this node.
205 kp.append(key)
206 dict[key] = CheckNode(value, kp)
207 return dict
208 elif isinstance(node, ast.List):
209 children = []
210 for index, child in enumerate(node.elts):
211 kp = list(keypath) # Copy list.
212 kp.append(repr(index))
213 children.append(CheckNode(child, kp))
214 return children
215 elif isinstance(node, ast.Str):
216 return node.s
217 else:
218 raise TypeError(
219 "Unknown AST node at key path '" + ".".join(keypath) + "': " + repr(node)
220 )
221
222
223def LoadOneBuildFile(build_file_path, data, aux_data, includes, is_target, check):

Callers 1

CheckedEvalFunction · 0.85

Calls 6

GypErrorClass · 0.90
zipFunction · 0.85
listFunction · 0.50
enumerateFunction · 0.50
joinMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected