diff src/ast_convert.rs @ 47:38f59b0efc2c

Handle Import and add a test for it.
author Bastien Orivel <eijebong@bananium.fr>
date Tue, 07 Jun 2016 12:51:36 +0200
parents 5f1d285471af
children 039f85b187f2
line wrap: on
line diff
--- a/src/ast_convert.rs
+++ b/src/ast_convert.rs
@@ -434,6 +434,7 @@ fn parse_statement(py: Python, ast: PyOb
     let aug_assign_type = ast_module.get(py, "AugAssign").unwrap();
     let return_type = ast_module.get(py, "Return").unwrap();
     let import_from_type = ast_module.get(py, "ImportFrom").unwrap();
+    let import_type = ast_module.get(py, "Import").unwrap();
     let if_type = ast_module.get(py, "If").unwrap();
     let while_type = ast_module.get(py, "While").unwrap();
     let for_type = ast_module.get(py, "For").unwrap();
@@ -545,6 +546,11 @@ fn parse_statement(py: Python, ast: PyOb
         let names = parse_list(py, names, parse_alias);
 
         stmt::ImportFrom(module, names, None)
+    } else if is_instance(&ast, &import_type) {
+        let names = ast.getattr(py, "names").unwrap();
+        let names = parse_list(py, names, parse_alias);
+
+        stmt::Import(names)
     } else if is_instance(&ast, &return_type) {
         let value = ast.getattr(py, "value").unwrap();
         if value == py.None() {