<commit_before>import logging.config
import os
import pkgutil

import yaml

from .configsection import ConfigSection
from .credentials import Credentials
from .general import General
from .machines import Machines
from .network import Network
from .pkgmgrs import PackageManagers
from .shells import Shells
from .virtualizers import Virtualizers


class Config(ConfigSection):
    @property
    def general(self):
        return self._general

    @property
    def credentials(self):
        return self._credentials

    @property
    def network(self):
        return self._network

    @property
    def virtualizers(self):
        return self._virtualizers

    @property
    def pkgmgrs(self):
        return self._pkgmgrs

    @property
    def shells(self):
        return self._shells

    @property
    def machines(self):
        return self._machines

    def load(self, config_path=None, log_dir=None):
        default_config = yaml.load(pkgutil.get_data('vmupdate', 'data/vmupdate.yaml'))

        if config_path:
            with open(config_path, 'r') as config_file:
                user_config = yaml.load(config_file)

            self._data = merge(default_config, user_config)
        else:
            self._data = default_config

        self._general = General(self._data['General'])
        self._credentials = Credentials(self._data['Credentials'])
        self._network = Network(self._data['Network'])
        self._virtualizers = Virtualizers(self._data['Virtualizers'])
        self._pkgmgrs = PackageManagers(self._data['Package Managers'])
        self._shells = Shells(self._data['Shells'])
        self._machines = Machines(self._data['Machines'])

        self._logging = yaml.load(pkgutil.get_data('vmupdate', 'data/logging.yaml'))

        if log_dir:
            self._set_log_filename(log_dir, 'info_file')
            self._set_log_filename(log_dir, 'error_file')<commit_msg>added default log dir<commit_after>import logging.config
import os
import pkgutil

import yaml

from vmupdate import BASE_DIR

from .configsection import ConfigSection
from .credentials import Credentials
from .general import General
from .machines import Machines
from .network import Network
from .pkgmgrs import PackageManagers
from .shells import Shells
from .virtualizers import Virtualizers


class Config(ConfigSection):
    @property
    def general(self):
        return self._general

    @property
    def credentials(self):
        return self._credentials

    @property
    def network(self):
        return self._network

    @property
    def virtualizers(self):
        return self._virtualizers

    @property
    def pkgmgrs(self):
        return self._pkgmgrs

    @property
    def shells(self):
        return self._shells

    @property
    def machines(self):
        return self._machines

    def load(self, config_path=None, log_dir=None):
        default_config = yaml.load(pkgutil.get_data('vmupdate', 'data/vmupdate.yaml'))

        if config_path:
            with open(config_path, 'r') as config_file:
                user_config = yaml.load(config_file)

            self._data = merge(default_config, user_config)
        else:
            self._data = default_config

        self._general = General(self._data['General'])
        self._credentials = Credentials(self._data['Credentials'])
        self._network = Network(self._data['Network'])
        self._virtualizers = Virtualizers(self._data['Virtualizers'])
        self._pkgmgrs = PackageManagers(self._data['Package Managers'])
        self._shells = Shells(self._data['Shells'])
        self._machines = Machines(self._data['Machines'])

        self._logging = yaml.load(pkgutil.get_data('vmupdate', 'data/logging.yaml'))

        if not log_dir:
            log_dir = BASE_DIR

        self._set_log_filename(log_dir, 'info_file')
        self._set_log_filename(log_dir, 'error_file')
{'fraction_non_alphanumeric': 0.09314857582755966, 'fraction_numerical': 0.0, 'mean_word_length': 2.9694501018329937, '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': '4861161', 'n_tokens_mistral': 1126, 'n_tokens_neox': 1080, 'n_words': 255}