<commit_before># -*- coding: utf-8 -*-
import re, sys, os, errno, time, shutil, tarfile, glob

from sjconfparts.type import *
from sjconfparts.plugin import *
from sjconfparts.conf import *
from sjconfparts.exceptions import *

class SJConf:

    DEFAULT_SJCONF_FILE_NAME = '/etc/smartjog/sjconf.conf'

    def __init__(self, sjconf_file_path = DEFAULT_SJCONF_FILE_NAME, verbose = False, logger = None):

        self.confs_internal = {'sjconf' : Conf(file_path = sjconf_file_path)}
        self.confs_internal['sjconf'].set_type('conf', 'plugins', 'list')

        self.backup_dir = os.path.realpath(self.confs_internal['sjconf']['conf']['backup_dir'] + '/' + time.strftime('%F-%R:%S', time.localtime()))
        self.etc_dir = os.path.realpath(self.confs_internal['sjconf']['conf']['etc_dir'])
        self.base_dir = os.path.realpath(self.confs_internal['sjconf']['conf']['base_dir'])

        self.confs = None
        self.plugins = None

        self.temp_file_path = "/tmp/sjconf_tempfile.conf"

        self.files_path = {
            'plugin' : os.path.realpath(self.confs_internal['sjconf']['conf']['plugins_path']),
            'template' : os.path.realpath(self.confs_internal['sjconf']['conf']['templates_path']),
            'conf' : self.base_dir + '/base',
            'profile' : self.base_dir + '/profiles'
        }
        self.files_extensions = {'plugin' : ('.py',), 'template' : ('.conf',), 'conf' : ('.conf',), 'profile' : ('.conf',)}

        sys.path.append(self.files_path['plugin'])

        self.verbose = verbose
        self.logger = logger

    def conf(self):
        self._load_confs()
        conf = self.conf_base()
        self._load_conf_local()
        conf.update(self.confs['local'])
        return conf

    def conf_typed(self):
        self._plugins_load()
        conf = self.conf()
        for plugin in self.plugins:
            for (section_name, section) in plugin.conf.iteritems():
                section = Conf.ConfSection(section) # Bypass plugin's class because we don't want the plugin to convert the key to its configuration file syntax
                for key in section:
                    type = section.get_type(key)
                    if type:
                        key_converted = Type.convert_key(key, type)
                        del conf[section_name][key]
                        conf[section_name][key_converted] = section[key_converted + '_' + type]
        return conf

    def conf_base(self):
        self._load_conf_base()
        conf = Conf(self.confs['base'])
        self._load_conf_profile()
        if 'profile' in self.confs:
            conf.update(self.confs['profile'])
        return conf
<commit_msg>Add “conf_local” method<commit_after># -*- coding: utf-8 -*-
import re, sys, os, errno, time, shutil, tarfile, glob

from sjconfparts.type import *
from sjconfparts.plugin import *
from sjconfparts.conf import *
from sjconfparts.exceptions import *

class SJConf:

    DEFAULT_SJCONF_FILE_NAME = '/etc/smartjog/sjconf.conf'

    def __init__(self, sjconf_file_path = DEFAULT_SJCONF_FILE_NAME, verbose = False, logger = None):

        self.confs_internal = {'sjconf' : Conf(file_path = sjconf_file_path)}
        self.confs_internal['sjconf'].set_type('conf', 'plugins', 'list')

        self.backup_dir = os.path.realpath(self.confs_internal['sjconf']['conf']['backup_dir'] + '/' + time.strftime('%F-%R:%S', time.localtime()))
        self.etc_dir = os.path.realpath(self.confs_internal['sjconf']['conf']['etc_dir'])
        self.base_dir = os.path.realpath(self.confs_internal['sjconf']['conf']['base_dir'])

        self.confs = None
        self.plugins = None

        self.temp_file_path = "/tmp/sjconf_tempfile.conf"

        self.files_path = {
            'plugin' : os.path.realpath(self.confs_internal['sjconf']['conf']['plugins_path']),
            'template' : os.path.realpath(self.confs_internal['sjconf']['conf']['templates_path']),
            'conf' : self.base_dir + '/base',
            'profile' : self.base_dir + '/profiles'
        }
        self.files_extensions = {'plugin' : ('.py',), 'template' : ('.conf',), 'conf' : ('.conf',), 'profile' : ('.conf',)}

        sys.path.append(self.files_path['plugin'])

        self.verbose = verbose
        self.logger = logger

    def conf(self):
        self._load_confs()
        conf = self.conf_base()
        self._load_conf_local()
        conf.update(self.confs['local'])
        return conf

    def conf_typed(self):
        self._plugins_load()
        conf = self.conf()
        for plugin in self.plugins:
            for (section_name, section) in plugin.conf.iteritems():
                section = Conf.ConfSection(section) # Bypass plugin's class because we don't want the plugin to convert the key to its configuration file syntax
                for key in section:
                    type = section.get_type(key)
                    if type:
                        key_converted = Type.convert_key(key, type)
                        del conf[section_name][key]
                        conf[section_name][key_converted] = section[key_converted + '_' + type]
        return conf

    def conf_local(self):
        self._load_conf_local()
        return Conf(self.confs['local'])

    def conf_base(self):
        self._load_conf_base()
        conf = Conf(self.confs['base'])
        self._load_conf_profile()
        if 'profile' in self.confs:
            conf.update(self.confs['profile'])
        return conf

{'fraction_non_alphanumeric': 0.1408527696793003, 'fraction_numerical': 0.00036443148688046647, 'mean_word_length': 2.5527508090614885, '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': '1582791', 'n_tokens_mistral': 1725, 'n_tokens_neox': 1673, 'n_words': 319}