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

Function appendCallToken

python/convert_ast.py:70–87  ·  view source on GitHub ↗
(callExpr, tokens)

Source from the content-addressed store, hash-verified

68 return SplootNode("PY_ARG", {'argument': [kwarg_node]})
69
70def appendCallToken(callExpr, tokens):
71 arguments = [SplootNode("PY_ARG", {'argument': [generateExpression(arg)]}) for arg in callExpr.args]
72 if len(arguments) == 0:
73 arguments = [SplootNode("PY_ARG", {'argument': []})]
74
75 keywords = [generateKeywordArgument(kwarg) for kwarg in callExpr.keywords]
76 arguments.extend(keywords)
77
78 if type(callExpr.func) == ast.Name:
79 name = callExpr.func.id
80 tokens.append(SplootNode('PYTHON_CALL_VARIABLE', {"arguments": arguments}, {"identifier": name}))
81 elif type(callExpr.func) == ast.Attribute:
82 attr = callExpr.func
83 obj = generateExpressionTokens(attr.value)
84 node = SplootNode('PYTHON_CALL_MEMBER', {'arguments': arguments, 'object': obj}, {'member': attr.attr})
85 tokens.append(node)
86 else:
87 raise Exception(f'Unsupported Call function expression: {ast.dump(callExpr.func)}')
88
89def appendAttribute(attrExpr, tokens):
90 obj = generateExpressionTokens(attrExpr.value)

Callers 1

generateExpressionTokensFunction · 0.85

Calls 4

generateExpressionFunction · 0.85
generateKeywordArgumentFunction · 0.85
generateExpressionTokensFunction · 0.85
SplootNodeFunction · 0.70

Tested by

no test coverage detected