1.1 --- a/micropython/data.py Tue Jul 10 01:36:34 2012 +0200
1.2 +++ b/micropython/data.py Tue Jul 10 18:54:33 2012 +0200
1.3 @@ -73,7 +73,7 @@
1.4 self.namespace = {}
1.5 self.globals = set()
1.6 self.lambdas = {} # only really useful for functions
1.7 - self.finalised = 0
1.8 + self.finalised = False
1.9
1.10 # Attributes accessed on objects, potentially narrowing their types.
1.11 # Specific namespaces should define known names during initialisation.
1.12 @@ -138,9 +138,9 @@
1.13 def vacuum_item(self, name):
1.14 if self.has_key(name):
1.15 del self[name]
1.16 - return 1
1.17 + return True
1.18 else:
1.19 - return 0
1.20 + return False
1.21
1.22 def add_lambda(self, obj):
1.23 attr = Attr(None, self, obj.name)
1.24 @@ -319,9 +319,9 @@
1.25 if not self.namespace.has_key(name):
1.26 self.globals.add(name)
1.27 self.define_scope(name, "global")
1.28 - return 1
1.29 + return True
1.30 else:
1.31 - return 0
1.32 + return False
1.33
1.34 # Attribute positioning.
1.35
1.36 @@ -347,13 +347,13 @@
1.37 for i, attr in enumerate(self.values()):
1.38 attr.position = i
1.39
1.40 - self.finalised = 1
1.41 + self.finalised = True
1.42
1.43 def unfinalise_attributes(self):
1.44
1.45 "Open attribute definitions to editing and subsequent finalisation."
1.46
1.47 - self.finalised = 0
1.48 + self.finalised = False
1.49
1.50 # Attribute usage methods.
1.51
1.52 @@ -984,7 +984,7 @@
1.53 "A class providing dictionaries which retain no information."
1.54
1.55 def has_key(self, name):
1.56 - return 0
1.57 + return False
1.58
1.59 def __setitem__(self, name, value):
1.60 pass
1.61 @@ -1143,14 +1143,14 @@
1.62 "Return whether this attribute defines more than one class."
1.63
1.64 if self.assignments > 1:
1.65 - have_class = 0
1.66 + have_class = False
1.67 for obj in self.get_values():
1.68 if isinstance(obj, Class):
1.69 if have_class:
1.70 - return 1
1.71 - have_class = 1
1.72 -
1.73 - return 0
1.74 + return True
1.75 + have_class = True
1.76 +
1.77 + return False
1.78
1.79 def defined_within_hierarchy(self):
1.80
1.81 @@ -1174,14 +1174,14 @@
1.82 context.has_subclass(self.parent) or
1.83 self.parent.has_subclass(context))
1.84 ):
1.85 - return 0
1.86 -
1.87 - return 1
1.88 + return False
1.89 +
1.90 + return True
1.91
1.92 # Instance attributes are not defined within a hierarchy.
1.93
1.94 else:
1.95 - return 0
1.96 + return False
1.97
1.98 def defined_outside_hierarchy(self):
1.99
1.100 @@ -1205,14 +1205,14 @@
1.101 context.has_subclass(self.parent) or
1.102 self.parent.has_subclass(context))
1.103 ):
1.104 - return 0
1.105 -
1.106 - return 1
1.107 + return False
1.108 +
1.109 + return True
1.110
1.111 # Instance attributes are not defined within a hierarchy.
1.112
1.113 else:
1.114 - return 0
1.115 + return False
1.116
1.117 def __repr__(self):
1.118 if self.position is not None:
1.119 @@ -1356,11 +1356,11 @@
1.120 # NOTE: Hack to prevent damage to exceptions.
1.121
1.122 if name == "_pc":
1.123 - return 0
1.124 + return False
1.125
1.126 if not NamespaceDict.vacuum_item(self, name):
1.127 self.instattr.remove(name)
1.128 - return 1
1.129 + return True
1.130
1.131 def finalise_attributes(self):
1.132
1.133 @@ -1371,14 +1371,14 @@
1.134
1.135 self.finalise_class_attributes()
1.136 self.finalise_instance_attributes()
1.137 - self.finalised = 1
1.138 + self.finalised = True
1.139
1.140 def unfinalise_attributes(self):
1.141
1.142 "Open attribute definitions to editing and subsequent finalisation."
1.143
1.144 self.reset_caches()
1.145 - self.finalised = 0
1.146 + self.finalised = False
1.147
1.148 # Convenience methods for accessing functions and methods.
1.149
1.150 @@ -1685,10 +1685,10 @@
1.151
1.152 if name is None:
1.153 self.name = "lambda#%d" % new_lambda()
1.154 - self._is_lambda = 1
1.155 + self._is_lambda = True
1.156 else:
1.157 self.name = name
1.158 - self._is_lambda = 0
1.159 + self._is_lambda = False
1.160
1.161 self.parent = parent
1.162 self.argnames = argnames
1.163 @@ -1804,11 +1804,11 @@
1.164 if self.dynamic is None:
1.165 for attr in self.default_attrs:
1.166 if not attr.is_strict_constant() and self.dynamic_def:
1.167 - self.dynamic = 1
1.168 + self.dynamic = True
1.169 self._make_dynamic()
1.170 break
1.171 else:
1.172 - self.dynamic = 0
1.173 + self.dynamic = False
1.174
1.175 return self.dynamic
1.176
1.177 @@ -1831,9 +1831,9 @@
1.178
1.179 if name not in self.argnames and not self.has_key(name):
1.180 self.globals.add(name)
1.181 - return 1
1.182 + return True
1.183 else:
1.184 - return 0
1.185 + return False
1.186
1.187 def parameters(self):
1.188
1.189 @@ -1899,8 +1899,8 @@
1.190
1.191 for cls in self.parent.descendants:
1.192 if name in cls.relocated:
1.193 - return 1
1.194 - return 0
1.195 + return True
1.196 + return False
1.197
1.198 # Administrative methods.
1.199
1.200 @@ -1909,7 +1909,7 @@
1.201
1.202 def vacuum_item(self, name):
1.203 del self.lambdas[name]
1.204 - return 1
1.205 + return True
1.206
1.207 def finalise_attributes(self):
1.208
1.209 @@ -1949,7 +1949,7 @@
1.210
1.211 self.local_usage = nothers
1.212 self.all_local_usage = nparams + nothers
1.213 - self.finalised = 1
1.214 + self.finalised = True
1.215
1.216 def _finalise_parameters(self):
1.217 if not self.argnames:
1.218 @@ -2174,22 +2174,22 @@
1.219 self.count = count
1.220
1.221 def __eq__(self, other):
1.222 - return 0
1.223 + return False
1.224
1.225 __lt__ = __le__ = __eq__
1.226
1.227 def __ne__(self, other):
1.228 - return 1
1.229 + return True
1.230
1.231 def __gt__(self, other):
1.232 if isinstance(other, AtLeast):
1.233 - return 0
1.234 + return False
1.235 else:
1.236 return self.count > other
1.237
1.238 def __ge__(self, other):
1.239 if isinstance(other, AtLeast):
1.240 - return 0
1.241 + return False
1.242 else:
1.243 return self.count >= other
1.244