diff src/ast_convert.rs @ 4:f27a4aee9dfa

Add ast.Attribute.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 31 May 2016 03:59:05 +0100
parents 326d7f2a94d4
children ddf372373a77
line wrap: on
line diff
--- a/src/ast_convert.rs
+++ b/src/ast_convert.rs
@@ -80,6 +80,7 @@ fn parse_expr(py: Python, ast: PyObject)
     let arg_type = ast_module.get(py, "arg").unwrap();
     let bin_op_type = ast_module.get(py, "BinOp").unwrap();
     let name_constant_type = ast_module.get(py, "NameConstant").unwrap();
+    let attribute_type = ast_module.get(py, "Attribute").unwrap();
     let name_type = ast_module.get(py, "Name").unwrap();
     let num_type = ast_module.get(py, "Num").unwrap();
     let str_type = ast_module.get(py, "Str").unwrap();
@@ -93,6 +94,14 @@ fn parse_expr(py: Python, ast: PyObject)
         let arg = ast.getattr(py, "arg").unwrap();
         let arg = get_str(py, arg);
         Expr::Name(arg)
+    } else if is_instance(&ast, &attribute_type) {
+        let value = ast.getattr(py, "value").unwrap();
+        let attr = ast.getattr(py, "attr").unwrap();
+
+        let value = parse_expr(py, value);
+        let attr = get_str(py, attr);
+
+        Expr::Attribute(Box::new(value), attr)
     } else if is_instance(&ast, &name_type) {
         let id = ast.getattr(py, "id").unwrap();
         let id = get_str(py, id);