Check to see if a file needs to be updated or created

def _check_touch(name, atime, mtime):
    '''
    Check to see if a file needs to be updated or created
    '''
    ret = {
        'result': None,
        'comment': '',
        'changes': {'new': name},
    }
    if not os.path.exists(name):
        ret['comment'] = 'File {0} is set to be created'.format(name)
    else:
        stats = __salt__['file.stats'](name, follow_symlinks=False)
        if ((atime is not None
             and six.text_type(atime) != six.text_type(stats['atime'])) or
            (mtime is not None
                and six.text_type(mtime) != six.text_type(stats['mtime']))):
            ret['comment'] = 'Times set to be updated on file {0}'.format(name)
            ret['changes'] = {'touched': name}
        else:
            ret['result'] = True
            ret['comment'] = 'File {0} exists and has the correct times'.format(name)
    return ret