<commit_before># -*- coding: utf-8 -*-
"""
This module provides all functionality for extending Python's suite class of functionality.

The module defines the class PymakeSuite.  The PymakeSuite class groups the different functionalities into a single class.
"""
import os
import configparser

from pymake.solution import PymakeSolution
from pymake.project import PymakeProject
from pymake.interpreter import PymakeInterpreter
from pymake.writer import PyWriteCommand
from pymake.register import PyRegisterCommand
from pymake.util.config import PymakeConfigParser

class PymakeSuite(object):
    
    def __init__(self, filename):
        
       # Read the configuration file
        config = PymakeConfigParser(interpolation=configparser.ExtendedInterpolation())
        config.read(filename)

        # Resolve the root path
        root = config.get('pymake', 'root', fallback=None)
        if not root:
            raise ValueError('Expected option "root" in section [pymake].')

        root = os.path.normpath(os.path.join(os.path.dirname(filename), root))
        config.set('pymake', 'root', root)

        # Build the Pymake Solutions
        self._solutions = [self._getsolution(config, s) for s in config.sections() if 'pymake.solution' in s]

        return super(PymakeSuite, self).__init__()
    
    def _getsolution(self, config, section, **kwargs):
        """
        Creates a Pymake solution from a configparser instance.

        :param obj config: The instance of the configparser class
        :param str section: The section name to read.
        :param **kwargs:  List of additional keyworded arguments to be passed into the PymakeSolution.
        :return: A valid PymakeSolution instance if succesful; None otherwise.
        """
        s = PymakeSolution(**kwargs)

        s.Name = config.get(section, 'name', fallback=s.Name)
        s.FileName = os.path.normpath(config.get(section, 'filename', fallback=s.FileName))<commit_msg>Added check for a valid configuration file to PymakeSuite constructor.<commit_after># -*- coding: utf-8 -*-
"""
This module provides all functionality for extending Python's suite class of functionality.

The module defines the class PymakeSuite.  The PymakeSuite class groups the different functionalities into a single class.
"""
import os
import configparser

from pymake.solution import PymakeSolution
from pymake.project import PymakeProject
from pymake.interpreter import PymakeInterpreter
from pymake.writer import PyWriteCommand
from pymake.register import PyRegisterCommand
from pymake.util.config import PymakeConfigParser

class PymakeSuite(object):
    
    def __init__(self, filename):
        """
        Constructor.

        :param str filename:  The fully qualified path to the Pymake configuration file.
        """ 
        # Read the configuration file
        config = PymakeConfigParser(interpolation=configparser.ExtendedInterpolation())
        if filename not in config.read(filename):
            raise ValueError('Could not read Pymake configuration file %s.' % filename)

        # Resolve the root path
        root = config.get('pymake', 'root', fallback=None)
        if not root:
            raise ValueError('Expected option "root" in section [pymake].')

        root = os.path.normpath(os.path.join(os.path.dirname(filename), root))
        config.set('pymake', 'root', root)

        # Build the Pymake Solutions
        self._solutions = [self._getsolution(config, s) for s in config.sections() if 'pymake.solution' in s]

        return super(PymakeSuite, self).__init__()
    
    def _getsolution(self, config, section, **kwargs):
        """
        Creates a Pymake solution from a configparser instance.

        :param obj config: The instance of the configparser class
        :param str section: The section name to read.
        :param **kwargs:  List of additional keyworded arguments to be passed into the PymakeSolution.
        :return: A valid PymakeSolution instance if succesful; None otherwise.
        """
        s = PymakeSolution(**kwargs)

        s.Name = config.get(section, 'name', fallback=s.Name)
        s.FileName = os.path.normpath(config.get(section, 'filename', fallback=s.FileName))
{'fraction_non_alphanumeric': 0.08659549228944247, 'fraction_numerical': 0.00047449584816132857, 'mean_word_length': 3.2845528455284554, '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': '58428', 'n_tokens_mistral': 1159, 'n_tokens_neox': 1138, 'n_words': 386}