<commit_before>
import os
import ConfigParser
import logging

logger = logging.getLogger(__name__)


search_paths = [".", "~/.igord", "/etc/igord"]

DATA_DIR = os.path.join(os.path.dirname(__file__), "data")

def flatten_config(cfg):
    cfgdict = {}
    for section in cfg.sections():
        for name, value in cfg.items(section):
            key = "%s.%s" % (section.lower(), name)
            cfgdict[key] = value
    return cfgdict

def parse_config(fn = "igord.cfg"):
    cfg = ConfigParser.SafeConfigParser()
    was_read = False
    for sp in search_paths:
        filename = os.path.join(sp, fn)
        if os.path.exists(filename):
            logger.info("Loading config from '%s'" % filename)
            cfg.read(filename)
            was_read = True
    assert was_read == True, "Config file not found"

    return flatten_config(cfg)<commit_msg>config: Break if config found<commit_after>
import os
import ConfigParser
import logging

logger = logging.getLogger(__name__)


search_paths = [".", "~/.igord", "/etc/igord"]

DATA_DIR = os.path.join(os.path.dirname(__file__), "data")

def flatten_config(cfg):
    cfgdict = {}
    for section in cfg.sections():
        for name, value in cfg.items(section):
            key = "%s.%s" % (section.lower(), name)
            cfgdict[key] = value
    return cfgdict

def parse_config(fn = "igord.cfg"):
    cfg = ConfigParser.SafeConfigParser()
    was_read = False
    for sp in search_paths:
        filename = os.path.join(sp, fn)
        if os.path.exists(filename):
            logger.info("Loading config from '%s'" % filename)
            cfg.read(filename)
            was_read = True
            break
    assert was_read == True, "Config file not found"

    return flatten_config(cfg)
{'fraction_non_alphanumeric': 0.12713797035347776, 'fraction_numerical': 0.0, 'mean_word_length': 2.7025316455696204, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6292660', 'n_tokens_mistral': 545, 'n_tokens_neox': 535, 'n_words': 140}