support dotted attributes in TreePath
authorStefan Behnel <scoder@users.berlios.de>
Fri, 4 Dec 2009 12:59:24 +0000 (13:59 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Fri, 4 Dec 2009 12:59:24 +0000 (13:59 +0100)
Cython/Compiler/TreePath.py

index 527fa6f0baba259c18d40c18d977e22b8f6b612a..fcecf8f6adbb5130444935c00e96d3ad5ad9d037 100644 (file)
@@ -144,11 +144,14 @@ def handle_attribute(next, token):
     else:
         if token[0] == '=':
             value = parse_path_value(next)
+    name_path = name.split('.')
     if value is None:
         def select(result):
             for node in result:
                 try:
-                    attr_value = getattr(node, name)
+                    attr_value = node
+                    for attr in name_path:
+                        attr_value = getattr(attr_value, attr)
                 except AttributeError:
                     continue
                 if attr_value is not None:
@@ -157,11 +160,13 @@ def handle_attribute(next, token):
         def select(result):
             for node in result:
                 try:
-                    attr_value = getattr(node, name)
+                    attr_value = node
+                    for attr in name_path:
+                        attr_value = getattr(attr_value, attr)
                 except AttributeError:
                     continue
                 if attr_value == value:
-                    yield value
+                    yield attr_value
     return select
 
 def parse_path_value(next):