Parse arguments to calls
This can be combined with the logic for parsing arguments to filters then they both generate the same AST.
This commit is contained in:
parent
d54d93ef2f
commit
1e98d2b19c
@ -256,9 +256,7 @@ def parse_variable_accessor(node, ast):
|
||||
accessor_node = nodes.Getattr()
|
||||
accessor_node.attr = ast['parameter']
|
||||
elif accessor_type == 'call':
|
||||
accessor_node = nodes.Call()
|
||||
accessor_node.args = []
|
||||
accessor_node.kwargs = []
|
||||
accessor_node = parse_variable_accessor_call(ast)
|
||||
|
||||
accessor_node.node = node
|
||||
accessor_node.ctx = "load"
|
||||
@ -266,6 +264,31 @@ def parse_variable_accessor(node, ast):
|
||||
|
||||
return accessor_node
|
||||
|
||||
def parse_variable_accessor_call(ast):
|
||||
args = []
|
||||
kwargs = []
|
||||
dynamic_args = None
|
||||
dynamic_kwargs = None
|
||||
|
||||
if ast['parameters']:
|
||||
for argument in ast['parameters']:
|
||||
value = parse_variable(argument['value'])
|
||||
|
||||
if 'key' in argument:
|
||||
kwargs.append(
|
||||
nodes.Keyword(argument['key'], value)
|
||||
)
|
||||
else:
|
||||
args.append(value)
|
||||
|
||||
node = nodes.Call()
|
||||
node.args = args
|
||||
node.kwargs = kwargs
|
||||
node.dyn_args = dynamic_args
|
||||
node.dyn_kwargs = dynamic_kwargs
|
||||
|
||||
return node
|
||||
|
||||
def parse_variable_filter(node, ast):
|
||||
args = []
|
||||
kwargs = []
|
||||
|
||||
Loading…
Reference in New Issue
Block a user