| 1156 | |
| 1157 | |
| 1158 | class List: |
| 1159 | def __init__(self, s=""): |
| 1160 | elements = [] |
| 1161 | if s.__class__ is str: |
| 1162 | # Have to handle escaped spaces correctly. |
| 1163 | elements = s.replace("\ ", "\001").split() |
| 1164 | else: |
| 1165 | elements = s |
| 1166 | self.l = [e.replace("\001", " ") for e in elements] |
| 1167 | |
| 1168 | def __len__(self): |
| 1169 | return len(self.l) |
| 1170 | |
| 1171 | def __getitem__(self, key): |
| 1172 | return self.l[key] |
| 1173 | |
| 1174 | def __setitem__(self, key, value): |
| 1175 | self.l[key] = value |
| 1176 | |
| 1177 | def __delitem__(self, key): |
| 1178 | del self.l[key] |
| 1179 | |
| 1180 | def __str__(self): |
| 1181 | return str(self.l) |
| 1182 | |
| 1183 | def __repr__(self): |
| 1184 | return "%s.List(%r)" % (self.__module__, " ".join(self.l)) |
| 1185 | |
| 1186 | def __mul__(self, other): |
| 1187 | result = List() |
| 1188 | if not isinstance(other, List): |
| 1189 | other = List(other) |
| 1190 | for f in self: |
| 1191 | for s in other: |
| 1192 | result.l.append(f + s) |
| 1193 | return result |
| 1194 | |
| 1195 | def __rmul__(self, other): |
| 1196 | if not isinstance(other, List): |
| 1197 | other = List(other) |
| 1198 | return List.__mul__(other, self) |
| 1199 | |
| 1200 | def __add__(self, other): |
| 1201 | result = List() |
| 1202 | result.l = self.l[:] + other.l[:] |
| 1203 | return result |
| 1204 | |
| 1205 | |
| 1206 | def _contains_lines(data, lines): |
no outgoing calls
no test coverage detected