'For a given file path searches for files with the same name but different extension and returns their absolute paths
:param file_path: The file to check for associated files
:return: A list containing all files which are associated to the given file'

def list_associated_files(self, file_path, subtitles_only=False, subfolders=False, rename=False):

    def recursive_glob(treeroot, pattern):
        results = []
        for (base, dirnames_, files) in ek(os.walk, treeroot.encode(sickbeard.SYS_ENCODING), followlinks=sickbeard.PROCESSOR_FOLLOW_SYMLINKS):
            goodfiles = fnmatch.filter(files, pattern)
            for f in goodfiles:
                found_file = ek(os.path.join, base, f)
                if (found_file != file_path):
                    results.append(found_file)
        return results
    if (not file_path):
        return []
    file_path_list_to_allow = []
    file_path_list_to_delete = []
    if subfolders:
        base_name = ek(os.path.basename, file_path).rpartition(u'.')[0]
    else:
        base_name = file_path.rpartition(u'.')[0]
    if (not base_name):
        return []
    dirname = (ek(os.path.dirname, file_path) or u'.')
    if subfolders:
        filelist = recursive_glob(dirname, (glob.escape(base_name) + u'*'))
    else:
        filelist = []
        for found_file in glob.glob(ek(os.path.join, glob.escape(dirname), u'*')):
            (file_name, separator, file_extension) = found_file.rpartition(u'.')
            if ((file_extension in SUBTITLE_EXTENSIONS) and (file_name.rpartition(u'.')[0].lower() == base_name.lower())):
                filelist.append(found_file)
            elif (file_name.lower() == base_name.lower()):
                filelist.append(found_file)
    for associated_file_path in filelist:
        if (os.path.abspath(associated_file_path) == os.path.abspath(file_path)):
            continue
        if rename:
            file_path_list_to_allow.append(associated_file_path)
            continue
        if (subtitles_only and (not associated_file_path.endswith(tuple(SUBTITLE_EXTENSIONS)))):
            continue
        if helpers.is_rar_file(associated_file_path):
            continue
        if ek(os.path.isfile, associated_file_path):
            if (sickbeard.MOVE_ASSOCIATED_FILES and associated_file_path.endswith(tuple(sickbeard.ALLOWED_EXTENSIONS.split(u',')))):
                file_path_list_to_allow.append(associated_file_path)
            elif sickbeard.DELETE_NON_ASSOCIATED_FILES:
                file_path_list_to_delete.append(associated_file_path)
    if (file_path_list_to_allow or file_path_list_to_delete):
        self._log(u'Found    the    following    associated    files    for    {0}:    {1}'.format(file_path, (file_path_list_to_allow + file_path_list_to_delete)), logger.DEBUG)
        if file_path_list_to_delete:
            self._log(u'Deleting    non    allowed    associated    files    for    {0}:    {1}'.format(file_path, file_path_list_to_delete), logger.DEBUG)
            self._delete(file_path_list_to_delete)
        if file_path_list_to_allow:
            self._log(u'Allowing    associated    files    for    {0}:    {1}'.format(file_path, file_path_list_to_allow), logger.DEBUG)
    else:
        self._log(u'No    associated    files    for    {0}    were    found    during    this    pass'.format(file_path), logger.DEBUG)
    return file_path_list_to_allow
