1.1 --- a/micropython/data.py Sun Oct 27 02:55:51 2013 +0200
1.2 +++ b/micropython/data.py Sun Oct 27 16:54:03 2013 +0100
1.3 @@ -392,16 +392,14 @@
1.4
1.5 "A basic attribute entry."
1.6
1.7 - def __init__(self, position, parent, name, parent_type=None):
1.8 + def __init__(self, parent, name, parent_type=None):
1.9
1.10 """
1.11 - Initialise the attribute with the given 'position' within the collection
1.12 - of attributes of its 'parent', indicating its 'name'. If the
1.13 - 'parent_type' is specified, it will contain the type of any instance
1.14 - parent.
1.15 + Initialise the attribute within the collection of attributes of its
1.16 + 'parent', indicating its 'name'. If the 'parent_type' is specified, it
1.17 + will contain the type of any instance parent.
1.18 """
1.19
1.20 - self.position = position
1.21 self.parent = parent
1.22 self.name = name
1.23 self.parent_type = parent_type
1.24 @@ -541,21 +539,19 @@
1.25 return True
1.26
1.27 def __repr__(self):
1.28 - if self.position is not None:
1.29 - position = "at %r, " % self.position
1.30 - else:
1.31 - position = ""
1.32 - if self.parent_type is not None:
1.33 - parent_type = "parent %s, " % shortrepr(self.parent_type)
1.34 - else:
1.35 - parent_type = ""
1.36 - return "<attribute %s.%s (%s%sassigned %r)>" % (
1.37 + return "<attribute %s.%s (%sassigned %r)>" % (
1.38 shortrepr(self.parent), self.name,
1.39 - parent_type, position, self.get_assignments()
1.40 + self._repr_parent_type(), self.get_assignments()
1.41 )
1.42
1.43 + def _repr_parent_type(self):
1.44 + if self.parent_type is not None:
1.45 + return "parent %s, " % shortrepr(self.parent_type)
1.46 + else:
1.47 + return ""
1.48 +
1.49 def __shortrepr__(self):
1.50 - return "%s.%s (at %r)" % (shortrepr(self.parent), self.name, self.position)
1.51 + return "%s.%s" % (shortrepr(self.parent), self.name)
1.52
1.53 class LocalAttr(BaseAttr):
1.54
1.55 @@ -601,7 +597,16 @@
1.56 "An attribute entry having context and value information."
1.57
1.58 def __init__(self, position, parent, name, parent_type=None):
1.59 - BaseAttr.__init__(self, position, parent, name, parent_type)
1.60 +
1.61 + """
1.62 + Initialise the attribute with the given 'position' within the collection
1.63 + of attributes of its 'parent', indicating its 'name'. If the
1.64 + 'parent_type' is specified, it will contain the type of any instance
1.65 + parent.
1.66 + """
1.67 +
1.68 + BaseAttr.__init__(self, parent, name, parent_type)
1.69 + self.position = position
1.70
1.71 # Possible values.
1.72
1.73 @@ -655,6 +660,23 @@
1.74 else:
1.75 self.assignments += AtLeast(n)
1.76
1.77 + def __repr__(self):
1.78 + return "<attribute %s.%s (%s%sassigned %r)>" % (
1.79 + shortrepr(self.parent), self.name,
1.80 + self._repr_parent_type(), self._repr_position(),
1.81 + self.get_assignments()
1.82 + )
1.83 +
1.84 + def _repr_position(self):
1.85 + if self.position is not None:
1.86 + return "at %r, " % self.position
1.87 + else:
1.88 + return ""
1.89 +
1.90 + def __shortrepr__(self):
1.91 + return "%s.%s (at %r)" % (shortrepr(self.parent), self.name,
1.92 + self._repr_position())
1.93 +
1.94 class Class(NamespaceDict, Naming, Constant):
1.95
1.96 "A base class for common/normal classes and the type class."