def replaceTexts(str):
    """
    The whole point of this function is to
    replace strings with __TEXTVAR_index__ and return a variable map dictionary

    :param str: the string that we want to make replacements on
    :return: replaced_str, text_var_map
    """
    text_var_map = {}
    ret = ''
    inside = False
    str_len = len(str)
    collected_text = ''
    text_var_count = 0
    skip_next = False
    for i, c in enumerate(str):
        if skip_next == True:
            skip_next = False
            continue
        next = '' if i >= str_len - 1 else str[i + 1]
        if c == "'" and not inside:
            inside = True
            text_var_count += 1
            continue
        if c == "'" and inside and next != "'":
            inside = False
            map_key = '__TEXTVAR_{text_var_count}__'.format(text_var_count=
                text_var_count)
            text_var_map[map_key] = collected_text
            collected_text = ''
            ret += map_key
            continue
        elif c == "'" and inside and next == "'":
            skip_next = True
            collected_text += "'"
        if inside == True:
            collected_text += c
        else:
            ret += c
    return ret, text_var_map
