<commit_before># -*- coding: utf-8 -*-
'''
(c) Copyright 2014 Telefonica, I+D. Printed in Spain (Europe). All Rights
Reserved.

The copyright to the software program(s) is property of Telefonica I+D.
The program(s) may be used and or copied only with the express written
consent of Telefonica I+D or in accordance with the terms and conditions
stipulated in the agreement/contract under which the program(s) have
been supplied.
'''
import logging.config
import ConfigParser
import os
import types


class Config(object):
    def initialize_logger(self):
        '''
        Read logger config file
        '''
        logging.config.fileConfig('conf/logging.conf')

    def initialize_config(self):
        '''
        Create config object with properties file and system properties
        '''
        config = ConfigParser.ConfigParser()
        config.read('conf/properties.cfg')

        # Get system properties and update config properties
        [self._get_system_property(config, section, option)
         for section in config.sections() for option in config.options(section)]

        # Add new methods to config object
        config = self._add_optional_methods(config)

        return config

    def _add_optional_methods(self, config):
        def get_optional(self, section, option, default=None):
            '''
            Get an option value for a given section
            If the section or the option are not found, the default value is returned
            '''
            try:
                return self.get(section, option)
            except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
                return default

        def getboolean_optional(self, section, option, default=False):
            '''
            Get an option boolean value for a given section
            If the section or the option are not found, the default value is returned
            '''
            try:<commit_msg>Preserve case reading config file<commit_after># -*- coding: utf-8 -*-
'''
(c) Copyright 2014 Telefonica, I+D. Printed in Spain (Europe). All Rights
Reserved.

The copyright to the software program(s) is property of Telefonica I+D.
The program(s) may be used and or copied only with the express written
consent of Telefonica I+D or in accordance with the terms and conditions
stipulated in the agreement/contract under which the program(s) have
been supplied.
'''
import logging.config
import ConfigParser
import os
import types


class Config(object):
    def initialize_logger(self):
        '''
        Read logger config file
        '''
        logging.config.fileConfig('conf/logging.conf')

    def initialize_config(self):
        '''
        Create config object with properties file and system properties
        '''
        config = ConfigParser.ConfigParser()
        config.optionxform = str
        config.read('conf/properties.cfg')

        # Get system properties and update config properties
        [self._get_system_property(config, section, option)
         for section in config.sections() for option in config.options(section)]

        # Add new methods to config object
        config = self._add_optional_methods(config)

        return config

    def _add_optional_methods(self, config):
        def get_optional(self, section, option, default=None):
            '''
            Get an option value for a given section
            If the section or the option are not found, the default value is returned
            '''
            try:
                return self.get(section, option)
            except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
                return default

        def getboolean_optional(self, section, option, default=False):
            '''
            Get an option boolean value for a given section
            If the section or the option are not found, the default value is returned
            '''
            try:
{'fraction_non_alphanumeric': 0.07282913165266107, 'fraction_numerical': 0.002546473134708429, 'mean_word_length': 2.497773820124666, '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': '2620184', 'n_tokens_mistral': 961, 'n_tokens_neox': 932, 'n_words': 383}