Close #2 - import-from
This commit is contained in:
parent
62c7044f37
commit
2a36c1e0c3
@ -60,6 +60,22 @@ def _ast_import(tree):
|
|||||||
return ast.Import(names=[ast.alias(name=str(x), asname=None) for x in c])
|
return ast.Import(names=[ast.alias(name=str(x), asname=None) for x in c])
|
||||||
|
|
||||||
|
|
||||||
|
def _ast_import_from(tree):
|
||||||
|
i = tree.get_invocation()
|
||||||
|
c = i['args']
|
||||||
|
mod = c.pop(0)
|
||||||
|
return ast.ImportFrom(
|
||||||
|
module=str(mod),
|
||||||
|
names=[
|
||||||
|
ast.alias(
|
||||||
|
name=str(x),
|
||||||
|
asname=None
|
||||||
|
) for x in c
|
||||||
|
],
|
||||||
|
level=0
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _ast_if(node, children, obj):
|
def _ast_if(node, children, obj):
|
||||||
cond = children.pop(0)
|
cond = children.pop(0)
|
||||||
true = children.pop(0)
|
true = children.pop(0)
|
||||||
@ -132,6 +148,7 @@ class AST27Converter(object):
|
|||||||
"defn": self._defn,
|
"defn": self._defn,
|
||||||
"def": self._def,
|
"def": self._def,
|
||||||
"import": _ast_import,
|
"import": _ast_import,
|
||||||
|
"import_from": _ast_import_from, # Remember, "-" --> "_"
|
||||||
|
|
||||||
"while": self._ast_while,
|
"while": self._ast_while,
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user