| 351 | |
| 352 | |
| 353 | class MoreItemsRange: |
| 354 | def __init__(self, value, from_i, to_i): |
| 355 | self.value = value |
| 356 | self.from_i = from_i |
| 357 | self.to_i = to_i |
| 358 | |
| 359 | def get_contents_debug_adapter_protocol(self, _self, fmt=None): |
| 360 | l = len(self.value) |
| 361 | ret = [] |
| 362 | |
| 363 | format_str = "%0" + str(int(len(str(l - 1)))) + "d" |
| 364 | if fmt is not None and fmt.get("hex", False): |
| 365 | format_str = "0x%0" + str(int(len(hex(l).lstrip("0x")))) + "x" |
| 366 | |
| 367 | for i, item in enumerate(self.value[self.from_i : self.to_i]): |
| 368 | i += self.from_i |
| 369 | ret.append((format_str % i, item, "[%s]" % i)) |
| 370 | return ret |
| 371 | |
| 372 | def get_dictionary(self, _self, fmt=None): |
| 373 | dct = {} |
| 374 | for key, obj, _ in self.get_contents_debug_adapter_protocol(self, fmt): |
| 375 | dct[key] = obj |
| 376 | return dct |
| 377 | |
| 378 | def resolve(self, attribute): |
| 379 | """ |
| 380 | :param var: that's the original object we're dealing with. |
| 381 | :param attribute: that's the key to resolve |
| 382 | -- either the dict key in get_dictionary or the name in the dap protocol. |
| 383 | """ |
| 384 | return self.value[int(attribute)] |
| 385 | |
| 386 | def __eq__(self, o): |
| 387 | return isinstance(o, MoreItemsRange) and self.value is o.value and self.from_i == o.from_i and self.to_i == o.to_i |
| 388 | |
| 389 | def __str__(self): |
| 390 | return "[%s:%s]" % (self.from_i, self.to_i) |
| 391 | |
| 392 | __repr__ = __str__ |
| 393 | |
| 394 | |
| 395 | class MoreItems: |
no outgoing calls
no test coverage detected