From 431738424914de1f1cf5c6cf9a4d3448205d684c Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Fri, 4 Dec 2009 13:59:24 +0100 Subject: [PATCH] support dotted attributes in TreePath --- Cython/Compiler/TreePath.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Cython/Compiler/TreePath.py b/Cython/Compiler/TreePath.py index 527fa6f0..fcecf8f6 100644 --- a/Cython/Compiler/TreePath.py +++ b/Cython/Compiler/TreePath.py @@ -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): -- 2.26.2