From: Stefan Behnel Date: Fri, 4 Dec 2009 12:59:24 +0000 (+0100) Subject: support dotted attributes in TreePath X-Git-Tag: 0.12.1~90 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=431738424914de1f1cf5c6cf9a4d3448205d684c;p=cython.git support dotted attributes in TreePath --- 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):