Reverses slice operations to take from the back of the packet, not the front
| 688 | |
| 689 | |
| 690 | class TrailerBytes(bytes): |
| 691 | """ |
| 692 | Reverses slice operations to take from the back of the packet, |
| 693 | not the front |
| 694 | """ |
| 695 | |
| 696 | def __getitem__(self, item): # type: ignore |
| 697 | # type: (Union[int, slice]) -> Union[int, bytes] |
| 698 | if isinstance(item, int): |
| 699 | if item < 0: |
| 700 | item = 1 + item |
| 701 | else: |
| 702 | item = len(self) - 1 - item |
| 703 | elif isinstance(item, slice): |
| 704 | start, stop, step = item.start, item.stop, item.step |
| 705 | new_start = -stop if stop else None |
| 706 | new_stop = -start if start else None |
| 707 | item = slice(new_start, new_stop, step) |
| 708 | return super(self.__class__, self).__getitem__(item) |
| 709 | |
| 710 | |
| 711 | class TrailerField(_FieldContainer): |
no outgoing calls
no test coverage detected
searching dependent graphs…