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

Function generateImportStatement

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

Source from the content-addressed store, hash-verified

436 return statements
437
438def generateImportStatement(import_node, traced, lineno):
439 aliases = []
440 moduleNames = import_node['childSets']['modules']
441 for moduleName in moduleNames:
442 aliases.append(ast.alias(moduleName['properties']['identifier']))
443
444 statements = [ast.Import(aliases)]
445 if not traced:
446 return statements
447
448 key = ast.Name(id=SPLOOT_KEY, ctx=ast.Load())
449 func = ast.Attribute(value=key, attr="startFrame", ctx=ast.Load())
450 import_start_frame = ast.Call(
451 func,
452 args=[
453 ast.Constant("PYTHON_IMPORT"),
454 ast.Constant("import"),
455 ],
456 keywords=[],
457 )
458 statements.insert(0, ast.Expr(import_start_frame, lineno=lineno, col_offset=0))
459
460 key = ast.Name(id=SPLOOT_KEY, ctx=ast.Load())
461 func = ast.Attribute(value=key, attr="endFrame", ctx=ast.Load())
462 call_end_frame = ast.Call(func, args=[], keywords=[])
463 statements.append(ast.Expr(call_end_frame, lineno=1, col_offset=0))
464 return statements
465
466def generateIfStatement(if_node, traced, lineno):
467 condition = generateAstExpression(if_node["childSets"]["condition"][0])

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected