From 68d469788d2ba3ab2103e7741ec95f500a92f10f Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 26 Jan 2018 14:29:22 -0500 Subject: [PATCH] Fix use of multi dot attributes in expressions It was formerly only assuming ability to bisect, now recurse to get the string out of nested attributes. --- confluent_server/confluent/config/configmanager.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/confluent_server/confluent/config/configmanager.py b/confluent_server/confluent/config/configmanager.py index ad028b2a..f5c96cbc 100644 --- a/confluent_server/confluent/config/configmanager.py +++ b/confluent_server/confluent/config/configmanager.py @@ -416,9 +416,14 @@ class _ExpressionFormat(string.Formatter): return node.n elif isinstance(node, ast.Attribute): #ok, we have something with a dot - left = node.value.id - right = node.attr - key = left + '.' + right + left = node + key = '' + while isinstance(left, ast.Attribute): + # Loop through, to handle multi dot expressions + # such as 'net.pxe.hwaddr' + key = '.' + left.attr + key + left = left.value + key = left.id + key val = self._expand_attribute(key) return val['value'] if val and 'value' in val else "" elif isinstance(node, ast.Name):