import re


def load_tolerances(fname):
    """ Load a dictionary with custom RMS limits.
    
    Dict keys are file (base)names, values are RMS limits to compare.
    """
    
    regexp = r'(?P<name>\w+\.png)\s+(?P<tol>[0-9\.]+)'
    
    dct = {}
    
    with open(fname, 'r') as f:
    
        for line in f:
            match = re.match(regexp, line)
            if match is None:
                continue
            dct[match.group('name')] = float(match.group('tol'))
            
    return dct