import configparser


def get_label_patterns(file):
    """
    Parse filename patterns from config file
        :param file: configuration file containing labeling rules
        :type file: file
        :returns: parsed labeling rules, False if something went wrong
        :rtype: dictionary, bool
    """
    config = configparser.ConfigParser()
    config.read_file(file)
    if config.has_section('labels') == False:
        return False
    opts = config.options('labels')
    ret = {}
    for o in opts:
        patterns = config.get('labels', o)
        patts = patterns.split('\n')
        if '' in patts:
            patts.remove('')
        ret[o] = patts
    return ret