'Takes a string, extracts complete lines from it, tests to see if they
are a prompt, error message, etc., and sets appropriate flags in self.
Prompt and success lines are removed.
Returns the processed (i.e. possibly-edited) output and the unprocessed
remainder (to be processed with the next chunk) as strings.'

def _examine_output(self, source, state, b_chunk, sudoable):

    output = []
    for b_line in b_chunk.splitlines(True):
        display_line = to_text(b_line).rstrip('\r\n')
        suppress_output = False
        if (self._play_context.prompt and self.check_password_prompt(b_line)):
            display.debug(("become_prompt:    (source=%s,    state=%s):    '%s'" % (source, state, display_line)))
            self._flags['become_prompt'] = True
            suppress_output = True
        elif (self._play_context.success_key and self.check_become_success(b_line)):
            display.debug(("become_success:    (source=%s,    state=%s):    '%s'" % (source, state, display_line)))
            self._flags['become_success'] = True
            suppress_output = True
        elif (sudoable and self.check_incorrect_password(b_line)):
            display.debug(("become_error:    (source=%s,    state=%s):    '%s'" % (source, state, display_line)))
            self._flags['become_error'] = True
        elif (sudoable and self.check_missing_password(b_line)):
            display.debug(("become_nopasswd_error:    (source=%s,    state=%s):    '%s'" % (source, state, display_line)))
            self._flags['become_nopasswd_error'] = True
        if (not suppress_output):
            output.append(b_line)
    remainder = ''
    if (output and (not output[(-1)].endswith('\n'))):
        remainder = output[(-1)]
        output = output[:(-1)]
    return (''.join(output), remainder)
