<commit_before>import os
import json

class ConfigMan:
    def __init__(self, conftype):
        if conftype == "module" or conftype == "service" or conftype == "perms":
            self.configpath = os.path.join(os.path.dirname(__file__), "configs" + os.sep + conftype + ".json")
        else:
            raise Exception("Invalid config type")
        self.values = self.load_values()

    def get_value(self, modname, valname, default="", writeDefault=True):
        if self.values.has_key(modname) and self.values[modname].has_key(valname):
            return self.values[modname][valname]
        else:
            if writeDefault:
                self.set_value(modname, valname, default)
            return default

    def set_value(self, modname, valname, value):
        if not self.values.has_key(modname):
            self.values[modname] = {}
        self.values[modname][valname] = value
        self.save_values()

    def load_values(self):
        try:
            config = open(self.configpath, "r")
            json_blocks = config.read()
            config.close()
            return json.loads(json_blocks)
        except:
            return {}

    def save_values(self):
        config = open(self.configpath, "w")
        config.write(json.dumps(self.values, sort_keys=True, indent=4, separators=(',', ': ')))<commit_msg>Changed load func<commit_after>import os
import json

class ConfigMan:
    def __init__(self, conftype):
        self.configpath = os.path.join(os.path.dirname(__file__), "configs" + os.sep + conftype + ".json")
        self.load_values()

    def get_value(self, modname, valname, default="", writeDefault=True):
        self.load_values()
        if self.values.has_key(modname) and self.values[modname].has_key(valname):
            return self.values[modname][valname]
        else:
            if writeDefault:
                self.set_value(modname, valname, default)
            return default

    def set_value(self, modname, valname, value):
        if not self.values.has_key(modname):
            self.values[modname] = {}
        self.values[modname][valname] = value
        self.save_values()

    def load_values(self):
        try:
            config = open(self.configpath, "r")
            json_blocks = config.read()
            config.close()
            self.values = json.loads(json_blocks)
        except:
            self.values = {}

    def save_values(self):
        config = open(self.configpath, "w")
        config.write(json.dumps(self.values, sort_keys=True, indent=4, separators=(',', ': ')))
{'fraction_non_alphanumeric': 0.12485414235705951, 'fraction_numerical': 0.0007779074290159471, 'mean_word_length': 2.3797634691195797, 'pattern_counts': {'":': 1, '<': 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': '6832703', 'n_tokens_mistral': 783, 'n_tokens_neox': 765, 'n_words': 158}