human
Complete the below
@webapi_decorator
def webapi_check_local_site(view_func):

    ''''Checks whether a user has access to a local site given in the URL.
    This decorator can be added to get/get_list methods to check whether or not
    a user should be able to view them given the local site name in the URL.'
    '''
 What is a the Python code you requested?
assistant
#Here is the Python code you requested.
    @webapi_response_errors(DOES_NOT_EXIST, NOT_LOGGED_IN, PERMISSION_DENIED)
    def _check(*args, **kwargs):
        request = _find_httprequest(args)
        local_site_name = kwargs.get(u'local_site_name', None)
        webapi_token = getattr(request, u'_webapi_token', None)
        if webapi_token:
            restrict_to_local_site = request._webapi_token.local_site_id
        else:
            restrict_to_local_site = None
        if local_site_name:
            local_site = get_object_or_none(LocalSite, name=local_site_name)
            if (not local_site):
                return DOES_NOT_EXIST
            elif (not local_site.is_accessible_by(request.user)):
                if request.user.is_authenticated():
                    logging.warning(u'%s    %s:    user    %s    does    not    have    access    to    local    site    "%s".', request.method, request.path_info, request.user.username, local_site_name)
                    return PERMISSION_DENIED
                else:
                    return NOT_LOGGED_IN
            elif (restrict_to_local_site and (restrict_to_local_site != local_site.pk)):
                logging.warning(u'%s    %s:    API    token    for    user    %s    does    not    have    access    to    local    site    "%s".', request.method, request.path_info, request.user.username, local_site_name)
                return PERMISSION_DENIED
            kwargs[u'local_site'] = local_site
        elif (restrict_to_local_site is not None):
            logging.warning(u'%s    %s:    API    token    for    user    %s    is    limited    to    a    local    site    but    the    request    was    for    the    root.', request.method, request.path_info, request.user.username)
            return PERMISSION_DENIED
        else:
            kwargs[u'local_site'] = None
        return view_func(*args, **kwargs)
    _check.checks_local_site = True
    return _check