import re


def _get_rating_for_regex_dict(fname, regex_dictionary):
    """
    iterate check if fname match to any item of regexlist,
    returns raiting for the best hit

    Parameters
    ----------
    fname : str
        File name.
    regex_dictionary : dict
        Dictionary of (regex, rating).

    Returns
    -------
    best_rating : int or None
        Returns the found raiting. None if no matching regex pattern was found.
    """
    best_rating = 0
    for reg, rating in regex_dictionary.items():
        if re.match(str(reg), fname) and rating > best_rating:
            best_rating = rating
    return best_rating