Parse isolated set blocks

This adds support for set blocks where a key-value pair is being
sent in so there is no matching pair of statement.
This commit is contained in:
Kevin 2020-05-10 13:59:23 -04:00
parent 1e98d2b19c
commit 807b6effbc

View File

@ -34,6 +34,9 @@ def parse_block(ast):
if block_name == 'from':
return parse_block_from(ast)
if block_name == 'set':
return parse_block_set(ast)
return None
def parse_block_pair(ast):
@ -117,6 +120,22 @@ def parse_block_if(ast):
lineno=lineno_from_parseinfo(ast['parseinfo'])
)
def parse_block_set(ast):
if 'block' in ast:
assignment = ast['block']['parameters'][0]
if isinstance(assignment['key'], str):
key = assignment['key']
else:
key = parse_variable(assignment['key'], variable_context="store")
return nodes.Assign(
key,
parse_variable(assignment['value']),
lineno=lineno_from_parseinfo(ast['parseinfo'])
)
return None
def parse_block_with(ast):
with_node = nodes.With(
lineno=lineno_from_parseinfo(ast['parseinfo'])