<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def has_code(state, text, incorrect_msg="The checker expected to find `{{text}}` in your command.", fixed=False):
 """Check whether the student code contains text. This function is a simpler override of the `has_code` function in protowhat, because ``ast_node._get_text()`` is not implemented in the OSH parser Using ``has_code()`` should be a last resort. It is always better to look at the result of code or the side effects they had on the state of your program. Args: state: State instance describing student and solution code. Can be omitted if used with Ex(). text : text that student code must contain. Can be a regex pattern or a simple string. incorrect_msg: if specified, this overrides the automatically generated feedback message in case ``text`` is not found in the student code. fixed: whether to match ``text`` exactly, rather than using regular expressions. :Example: Suppose the solution requires you to do: :: git push origin master The following SCT can be written: :: Ex().has_code(r'git\\s+push\\s+origin\\s+master') Submissions that would pass: :: git push origin master git push origin master Submissions that would fail: :: git push --force origin master """


    stu_code = state.student_code

    # either simple text matching or regex test
    res = text in stu_code if fixed else re.search(text, stu_code)

    if not res:
        _msg = state.build_message(incorrect_msg, fmt_kwargs={ 'text': text })
        state.do_test(_msg)

    return state