import difflib


def get_best_match(texts, match_against, ignore=' ', treshold=0.9):
    """Get the best matching from texts, none if treshold is not reached
    
    texts: list of texts to choose from
    match_against: text wanted
    ignore: junk characters (set eg to "_ ")
    treshold: best match must be at least this value.
    
    """
    # JUNK =  space _
    # now time to figre out the matching
    ratio_calc = difflib.SequenceMatcher(lambda x: x in ignore)
    ratio_calc.set_seq1(match_against)

    ratios = {}
    best_ratio = 0
    best_text = ''

    for text in texts:
        # set up the SequenceMatcher with other text
        ratio_calc.set_seq2(text)

        # calculate ratio and store it
        ratios[text] = ratio_calc.ratio()

        # if this is the best so far then update best stats
        if ratios[text] > best_ratio:
            best_ratio = ratios[text]
            best_text = text

    if best_ratio > treshold:
        return best_text