MCPcopy Index your code
hub / github.com/nodejs/node / LoadPythonDictionary

Function LoadPythonDictionary

tools/gypi_to_gn.py:220–251  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

218
219
220def LoadPythonDictionary(path):
221 file_string = open(path).read()
222 try:
223 file_data = eval(file_string, {'__builtins__': None}, None)
224 except SyntaxError as e:
225 e.filename = path
226 raise
227 except Exception as e:
228 raise Exception("Unexpected error while reading %s: %s" % (path, str(e)))
229
230 assert isinstance(file_data, dict), "%s does not eval to a dictionary" % path
231
232 # Flatten any variables to the top level.
233 if 'variables' in file_data:
234 file_data.update(file_data['variables'])
235 del file_data['variables']
236
237 # Strip all elements that this script can't process.
238 elements_to_strip = [
239 'conditions',
240 'direct_dependent_settings',
241 'target_conditions',
242 'target_defaults',
243 'targets',
244 'includes',
245 'actions',
246 ]
247 for element in elements_to_strip:
248 if element in file_data:
249 del file_data[element]
250
251 return file_data
252
253
254def ReplaceSubstrings(values, search_for, replace_with):

Callers 1

mainFunction · 0.85

Calls 5

strFunction · 0.85
updateMethod · 0.65
openFunction · 0.50
evalFunction · 0.50
readMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…