code: def frameify(self, state, data):
          
  
          # Pull in any partially-processed data
          data = state.recv_buf + data
  
          # Loop over the data
          while data:
              if not state.frame_start:
                  try:
                      idx = data.index(self.prefix + self.begin)
                  except ValueError:
                      # Can't find the start of a frame...
                      break
  
                  # Advance data to the beginning of the frame (just
                  # after the marker)
                  data = data[idx + len(self.prefix) + 1:]
                  state.frame_start = True
  
              # Now that data is sitting at the frame start, let's find
              # the frame ending
              try:
                  idx = data.index(self.prefix + self.end)
              except ValueError:
                  # Can't find the end of the frame...
                  break
  
              # OK, extract the frame and advance the data
              frame = data[:idx]
              data = data[idx + len(self.prefix) + 1:]
              state.frame_start = (self.begin == self.end)
  
              # Now we need to unstuff the frame
              frame = self.prefix.join(frame.split(self.prefix + self.nop))
  
              # Yield the frame
              try:
                  yield frame
              except FrameSwitch:
                  break
  
          # Put any remaining data back into the buffer
          state.recv_buf = data
docs: Split data into a sequence of frames.