'Remove the frames according to the paste spec.'

def filter_hidden_frames(self):

    if (not self.frames):
        return
    new_frames = []
    hidden = False
    for frame in self.frames:
        hide = frame.hide
        if (hide in ('before', 'before_and_this')):
            new_frames = []
            hidden = False
            if (hide == 'before_and_this'):
                continue
        elif (hide in ('reset', 'reset_and_this')):
            hidden = False
            if (hide == 'reset_and_this'):
                continue
        elif (hide in ('after', 'after_and_this')):
            hidden = True
            if (hide == 'after_and_this'):
                continue
        elif (hide or hidden):
            continue
        new_frames.append(frame)
    if ((len(new_frames) == 1) and (self.frames[0].module == 'codeop')):
        del self.frames[:]
    elif (self.frames[(-1)] in new_frames):
        self.frames[:] = new_frames
