MCPcopy Create free account
hub / github.com/SplootCode/splootcode / generateFromImportStatement

Function generateFromImportStatement

python/executor.py:410–436  ·  view source on GitHub ↗
(import_node, traced, lineno)

Source from the content-addressed store, hash-verified

408 return statements
409
410def generateFromImportStatement(import_node, traced, lineno):
411 moduleName = import_node['childSets']['module'][0]['properties']['identifier']
412 attrNames = []
413 for attrNode in import_node['childSets']['attrs']:
414 attrNames.append(ast.alias(attrNode['properties']['identifier']))
415
416 statements = [ast.ImportFrom(moduleName, attrNames, 0)]
417 if not traced:
418 return statements
419
420 key = ast.Name(id=SPLOOT_KEY, ctx=ast.Load())
421 func = ast.Attribute(value=key, attr="startFrame", ctx=ast.Load())
422 import_start_frame = ast.Call(
423 func,
424 args=[
425 ast.Constant("PYTHON_FROM_IMPORT"),
426 ast.Constant("import"),
427 ],
428 keywords=[],
429 )
430 statements.insert(0, ast.Expr(import_start_frame, lineno=lineno, col_offset=0))
431
432 key = ast.Name(id=SPLOOT_KEY, ctx=ast.Load())
433 func = ast.Attribute(value=key, attr="endFrame", ctx=ast.Load())
434 call_end_frame = ast.Call(func, args=[], keywords=[])
435 statements.append(ast.Expr(call_end_frame, lineno=1, col_offset=0))
436 return statements
437
438def generateImportStatement(import_node, traced, lineno):
439 aliases = []

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected