def METHOD_NAME(
    target_name, variable, variable_trace, initial, is_dict, emit, context
):
    # TODO: Variable could known to be set here, get a hand at that
    # information.
    variable_declaration = getLocalVariableDeclaration(
        context, variable, variable_trace
    )
    variable_c_type = variable_declaration.getCType()
    test_code = variable_c_type.getInitTestConditionCode(
        value_name=variable_declaration, inverted=False
    )
    access_code = SourceCodeCollector()
    getVariableReferenceCode(
        to_name=VariableDeclaration("PyObject *", "value", None, None),
        variable=variable,
        variable_trace=variable_trace,
        needs_check=False,
        conversion_check=True,
        emit=access_code,
        context=context,
    )
    if is_dict:
        if initial:
            template = template_set_locals_dict_value
        else:
            template = template_update_locals_dict_value
        emit(
            template
            % {
                "dict_name": target_name,
                "var_name": context.getConstantCode(constant=variable.getName()),
                "test_code": test_code,
                "access_code": indented(access_code.codes),
            }
        )
    else:
        if initial:
            template = template_set_locals_mapping_value
        else:
            template = template_update_locals_mapping_value
        res_name = context.getBoolResName()
        emit(
            template
            % {
                "mapping_name": target_name,
                "var_name": context.getConstantCode(constant=variable.getName()),
                "test_code": test_code,
                "access_code": access_code,
                "tmp_name": res_name,
            }
        )
        getErrorExitBoolCode(
            condition="%s == false" % res_name, emit=emit, context=context
        )