while loop
This commit is contained in:
parent
63a276692a
commit
952ba5811e
@ -123,7 +123,10 @@ class AST27Converter(object):
|
|||||||
"def": self._def,
|
"def": self._def,
|
||||||
"import": _ast_import,
|
"import": _ast_import,
|
||||||
|
|
||||||
"doseq": self._ast_for, "for": self._ast_for,
|
"while": self._ast_while,
|
||||||
|
|
||||||
|
"doseq": self._ast_for,
|
||||||
|
"for": self._ast_for,
|
||||||
}
|
}
|
||||||
|
|
||||||
def _def(self, node):
|
def _def(self, node):
|
||||||
@ -139,6 +142,22 @@ class AST27Converter(object):
|
|||||||
)
|
)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
def _ast_while(self, node):
|
||||||
|
i = node.get_invocation()
|
||||||
|
args = i['args']
|
||||||
|
test = args.pop(0)
|
||||||
|
test = self.render(test)
|
||||||
|
body = args.pop(0)
|
||||||
|
body = self.render(body)
|
||||||
|
body = body if isinstance(body, list) else [body]
|
||||||
|
|
||||||
|
return ast.While(
|
||||||
|
test=test,
|
||||||
|
body=body,
|
||||||
|
orelse=[]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _ast_for(self, node):
|
def _ast_for(self, node):
|
||||||
i = node.get_invocation()
|
i = node.get_invocation()
|
||||||
args = i['args']
|
args = i['args']
|
||||||
|
Loading…
Reference in New Issue
Block a user