<commit_before># Python imports
from ConfigParser import ConfigParser, NoOptionError, NoSectionError
import re


class Config(ConfigParser):
    NoOptionError = NoOptionError
    NoSectionError = NoSectionError

    def __init__(self, filename, *args, **kwargs):
        ConfigParser.__init__(self, *args, **kwargs)
        self.read([filename])

    def getdefault(self, section, option, default=None):
        try:
            return self.get(section, option)
        except (NoOptionError, NoSectionError):
            return default

    def getlist(self, section, option, sep=','):
        value = self.get(section, option)
        return map(lambda item: item.strip(), value.split(sep))

    def getmulti(self, section, option, strip_comments=True):
        multi = []
        for item in self.getlist(section, option, '\n'):
            if strip_comments:
                item = item.split(' #', 1)[0].rstrip()
            multi.append(item)
        return multi<commit_msg>Properly handle multi line items<commit_after># Python imports
from ConfigParser import ConfigParser, NoOptionError, NoSectionError
import re


class Config(ConfigParser):
    NoOptionError = NoOptionError
    NoSectionError = NoSectionError

    re_padding = re.compile(r'(^[\s\t,]+|[\s\t,]+$)')

    def __init__(self, filename, *args, **kwargs):
        ConfigParser.__init__(self, *args, **kwargs)
        self.read([filename])

    def getdefault(self, section, option, default=None):
        try:
            return self.get(section, option)
        except (NoOptionError, NoSectionError):
            return default

    def getlist(self, section, option, sep=','):
        value = self.get(section, option)
        return map(lambda item: item.strip(), value.split(sep))

    def getmulti(self, section, option, strip_comments=True):
        multi = []
        for item in self.get(section, option).splitlines():
            # Remove comments, if enabled
            if strip_comments:
                item = item.rsplit(' #', 1)[0]

            # Clean up padding
            item = self.re_padding.sub('', item)
            multi.append(item)
        return multi
{'fraction_non_alphanumeric': 0.11606313834726091, 'fraction_numerical': 0.0018570102135561746, 'mean_word_length': 2.7155172413793105, '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': '5283823', 'n_tokens_mistral': 603, 'n_tokens_neox': 585, 'n_words': 160}