# HG changeset patch # User Paul Boddie # Date 1382476898 -7200 # Node ID 5aaa10d8130fabbda4d988988ea844d27ad37f99 # Parent 1abb7ebf810f5d6382940bd18a637e6800337614 Improved reporting of possible attribute values in certain cases, such as where an _attr annotation may be present and reference several different attribute values as opposed to just a single attribute value. diff -r 1abb7ebf810f -r 5aaa10d8130f micropython/report.py --- a/micropython/report.py Thu Oct 17 17:07:39 2013 +0200 +++ b/micropython/report.py Tue Oct 22 23:21:38 2013 +0200 @@ -451,32 +451,27 @@ return fullname - def _attributes_to_target_names(self, attributes): + def _attributes_to_names(self, attributes, target=False): - "Get the target names for the 'attributes'." + """ + Get the names for the 'attributes' or their targets (if 'target' is set + to a true value). + """ - output = [] + output = set() if attributes: for attr, value in attributes: - fullname = self._attribute_value_to_name(attr, value, True) - if fullname: - output.append(fullname) - - output.sort() - return output - - def _attributes_to_attribute_names(self, attributes): + values = value and [value] or attr and attr.get_values() or [None] - "Get the output form of the 'attributes'." - - output = [] + for value in values: + fullname = self._attribute_value_to_name(attr, value, target) + if target and fullname: + output.add(fullname) + elif not target: + output.add((fullname, value)) - if attributes: - for attr, value in attributes: - fullname = self._attribute_value_to_name(attr, value, False) - output.append((fullname, value)) - + output = list(output) output.sort() return output @@ -956,7 +951,7 @@ self.stream.write("
\n") self._keyword("print") if node.dest is not None: - self.stream.write(">>\n") + self.stream.write(self._text(">>\n")) self.dispatch(node.dest) self.stream.write(",\n") for n in node.nodes: @@ -968,7 +963,7 @@ self.stream.write("
\n") self._keyword("print") if node.dest is not None: - self.stream.write(">>\n") + self.stream.write(self._text(">>\n")) self.dispatch(node.dest) first = False else: @@ -1148,7 +1143,8 @@ node._attrs_deduced or \ map(self.get_attribute_and_value, node._attrs_deduced_from_specific_usage or []) - possible_types = self._attributes_to_target_names(attributes) + possible_types = self._attributes_to_names(attributes, True) + attribute_names = self._attributes_to_names(attributes) wraps_getattr = self._has_descendant(node.expr, compiler.ast.Getattr) @@ -1160,9 +1156,9 @@ self._accessor_end(possible_types) self.stream.write(".") - self._attribute_start(node.attrname, self._attributes_to_attribute_names(attributes)) + self._attribute_start(node.attrname, attribute_names) self._span(node.attrname, "attrname" + ((not attributes or node._access_type == "impossible") and " no-attributes" or "")) - self._attribute_end(attributes) + self._attribute_end(attribute_names) if not wraps_getattr: self._span_end()