<commit_before>import os
import configparser

from xdg import BaseDirectory
from urllib.parse import urlparse


class Config(object):
    def __init__(self):
        self._cparser = configparser.ConfigParser()

        paths = list(BaseDirectory.load_config_paths("mnemosyne"))
        paths.append(os.getcwd())

        for path in paths:
            file = os.path.join(path, "mnemosyne.ini")

            if os.path.exists(file):
                self._cparser.read(file)

        self.consumer = Config.Consumer(self._cparser)
        self.web = Config.Web(self._cparser)


    class Consumer(object):
        name = 'consumer'

        def __init__(self, config):
            self.uri = urlparse(config.get(self.name, 'uri', fallback='amqp://'))
            self.queue_name = config.get(self.name, 'queue', fallback='mnemosyne-server')
            self.exchange_name = config.get(self.name, 'exchange', fallback='mnemosyne')


    class Web(object):
        name = 'web'

        def __init__(self, config):
            self.port = urlparse(config.get(self.name, 'port', fallback=None))


config = Config()<commit_msg>Fix config parser<commit_after>import os
import configparser

from xdg import BaseDirectory
from urllib.parse import urlparse


class Config(object):
    def __init__(self):
        self._cparser = configparser.ConfigParser()

        paths = list(BaseDirectory.load_config_paths("mnemosyne"))
        paths.append(os.getcwd())

        for path in paths:
            file = os.path.join(path, "mnemosyne.ini")

            if os.path.exists(file):
                self._cparser.read(file)

        self.consumer = Config.Consumer(self._cparser)
        self.web = Config.Web(self._cparser)


    class Consumer(object):
        name = 'consumer'

        def __init__(self, config):
            self.uri = urlparse(config.get(self.name, 'uri', fallback='amqp://'))
            self.queue_name = config.get(self.name, 'queue', fallback='mnemosyne-server')
            self.exchange_name = config.get(self.name, 'exchange', fallback='mnemosyne')


    class Web(object):
        name = 'web'

        def __init__(self, config):
            self.port = int(config.get(self.name, 'port', fallback=None))


config = Config()
{'fraction_non_alphanumeric': 0.12572447614801605, 'fraction_numerical': 0.0, 'mean_word_length': 2.6369529983792543, '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': '2181927', 'n_tokens_mistral': 706, 'n_tokens_neox': 659, 'n_words': 135}