Exemplo n.º 1
0
 def last(self) -> Packet:
     """
     :return: the last packet found
     """
     if self._last_index >= 0:
         return self._pkts[self._last_index]
     else:
         raise errors.PacketNotFound(self.index, self._stop_index)
Exemplo n.º 2
0
    def must_next(self) -> Packet:
        """
        Call .next(), raise error if packet is not found.

        :return: the next matching packet
        """
        p = self.next()
        if p is not None:
            return p
        else:
            raise errors.PacketNotFound(self.index, self._stop_index)