Set the return code based on the data back from the state system

def _set_retcode(ret, highstate=None):
    '''
    Set the return code based on the data back from the state system
    '''

    # Set default retcode to 0
    __context__['retcode'] = salt.defaults.exitcodes.EX_OK

    if isinstance(ret, list):
        __context__['retcode'] = salt.defaults.exitcodes.EX_STATE_COMPILER_ERROR
        return
    if not __utils__['state.check_result'](ret, highstate=highstate):
        __context__['retcode'] = salt.defaults.exitcodes.EX_STATE_FAILURE