1.1 --- a/micropython/report.py Thu Oct 17 17:07:39 2013 +0200
1.2 +++ b/micropython/report.py Tue Oct 22 23:21:38 2013 +0200
1.3 @@ -451,32 +451,27 @@
1.4
1.5 return fullname
1.6
1.7 - def _attributes_to_target_names(self, attributes):
1.8 + def _attributes_to_names(self, attributes, target=False):
1.9
1.10 - "Get the target names for the 'attributes'."
1.11 + """
1.12 + Get the names for the 'attributes' or their targets (if 'target' is set
1.13 + to a true value).
1.14 + """
1.15
1.16 - output = []
1.17 + output = set()
1.18
1.19 if attributes:
1.20 for attr, value in attributes:
1.21 - fullname = self._attribute_value_to_name(attr, value, True)
1.22 - if fullname:
1.23 - output.append(fullname)
1.24 -
1.25 - output.sort()
1.26 - return output
1.27 -
1.28 - def _attributes_to_attribute_names(self, attributes):
1.29 + values = value and [value] or attr and attr.get_values() or [None]
1.30
1.31 - "Get the output form of the 'attributes'."
1.32 -
1.33 - output = []
1.34 + for value in values:
1.35 + fullname = self._attribute_value_to_name(attr, value, target)
1.36 + if target and fullname:
1.37 + output.add(fullname)
1.38 + elif not target:
1.39 + output.add((fullname, value))
1.40
1.41 - if attributes:
1.42 - for attr, value in attributes:
1.43 - fullname = self._attribute_value_to_name(attr, value, False)
1.44 - output.append((fullname, value))
1.45 -
1.46 + output = list(output)
1.47 output.sort()
1.48 return output
1.49
1.50 @@ -956,7 +951,7 @@
1.51 self.stream.write("<div class='print nowrap'>\n")
1.52 self._keyword("print")
1.53 if node.dest is not None:
1.54 - self.stream.write(">>\n")
1.55 + self.stream.write(self._text(">>\n"))
1.56 self.dispatch(node.dest)
1.57 self.stream.write(",\n")
1.58 for n in node.nodes:
1.59 @@ -968,7 +963,7 @@
1.60 self.stream.write("<div class='printnl nowrap'>\n")
1.61 self._keyword("print")
1.62 if node.dest is not None:
1.63 - self.stream.write(">>\n")
1.64 + self.stream.write(self._text(">>\n"))
1.65 self.dispatch(node.dest)
1.66 first = False
1.67 else:
1.68 @@ -1148,7 +1143,8 @@
1.69 node._attrs_deduced or \
1.70 map(self.get_attribute_and_value, node._attrs_deduced_from_specific_usage or [])
1.71
1.72 - possible_types = self._attributes_to_target_names(attributes)
1.73 + possible_types = self._attributes_to_names(attributes, True)
1.74 + attribute_names = self._attributes_to_names(attributes)
1.75
1.76 wraps_getattr = self._has_descendant(node.expr, compiler.ast.Getattr)
1.77
1.78 @@ -1160,9 +1156,9 @@
1.79 self._accessor_end(possible_types)
1.80
1.81 self.stream.write(".")
1.82 - self._attribute_start(node.attrname, self._attributes_to_attribute_names(attributes))
1.83 + self._attribute_start(node.attrname, attribute_names)
1.84 self._span(node.attrname, "attrname" + ((not attributes or node._access_type == "impossible") and " no-attributes" or ""))
1.85 - self._attribute_end(attributes)
1.86 + self._attribute_end(attribute_names)
1.87
1.88 if not wraps_getattr:
1.89 self._span_end()