<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def frameify(self, state, data):
 """Yield chunk data as a single frame, and buffer the rest."""


        # If we've pulled in all the chunk data, buffer the data
        if state.chunk_remaining <= 0:
            state.recv_buf += data
            return

        # Pull in any partially-processed data
        data = state.recv_buf + data

        # Determine how much belongs to the chunk
        if len(data) <= state.chunk_remaining:
            chunk = data
            data = ''
        else:
            # Pull out only what's part of the chunk
            chunk = data[:state.chunk_remaining]
            data = data[state.chunk_remaining:]

        # Update the state
        state.recv_buf = data
        state.chunk_remaining -= len(chunk)

        # Yield the chunk
        try:
            yield chunk
        except FrameSwitch:
            pass