<commit_before>"""
Copyright (c) 2015 Red Hat, Inc
All rights reserved.

This software may be modified and distributed under the terms
of the MIT license. See the LICENSE file for details.
"""

import logging

from cct.module import ModuleManager, ModuleRunner, Module

logger = logging.getLogger('cct')


class ChangeProcessor(object):
    config = None

    def __init__(self, config, modules_dir, artifacts_dir):
        self.config = config
        self.modules_dir = modules_dir
        self.artifacts_dir = artifacts_dir

    def process(self, fetch_only=False):
        logger.debug("processing change %s" % self.config)
        for change in self.config:
            return self._process_change(change, fetch_only)

    def _merge_environment(self, change_env, module_env):
        if change_env is None:
            return module_env
        if module_env is None:
            return change_env
        combined = {}
        combined.update(change_env)
        combined.update(module_env)
        return combined

    def _create_env_dict(self, env):
        env_dict = {}
        if env is None:
            return env_dict
        for variable in env:
            env_dict[variable] = env[variable]
        return env_dict

    def _process_change(self, change_cfg, fetch_only):
        logger.info("processing change %s" % change_cfg['name'])
        change_env = self._create_env_dict(change_cfg.get('environment'))
        if 'description' not in change_cfg:
            change_cfg['description'] = None
        mr = ModuleManager(self.modules_dir, self.artifacts_dir)
<commit_msg>made change name optional attribute<commit_after>"""
Copyright (c) 2015 Red Hat, Inc
All rights reserved.

This software may be modified and distributed under the terms
of the MIT license. See the LICENSE file for details.
"""

import logging

from cct.module import ModuleManager, ModuleRunner, Module

logger = logging.getLogger('cct')


class ChangeProcessor(object):
    config = None

    def __init__(self, config, modules_dir, artifacts_dir):
        self.config = config
        self.modules_dir = modules_dir
        self.artifacts_dir = artifacts_dir

    def process(self, fetch_only=False):
        logger.debug("processing change %s" % self.config)
        for change in self.config:
            return self._process_change(change, fetch_only)

    def _merge_environment(self, change_env, module_env):
        if change_env is None:
            return module_env
        if module_env is None:
            return change_env
        combined = {}
        combined.update(change_env)
        combined.update(module_env)
        return combined

    def _create_env_dict(self, env):
        env_dict = {}
        if env is None:
            return env_dict
        for variable in env:
            env_dict[variable] = env[variable]
        return env_dict

    def _process_change(self, change_cfg, fetch_only):
        if 'name' not in change_cfg:
            change_cfg['name'] = ''
        logger.info("processing change %s" % change_cfg['name'])
        change_env = self._create_env_dict(change_cfg.get('environment'))
        if 'description' not in change_cfg:
            change_cfg['description'] = None
        mr = ModuleManager(self.modules_dir, self.artifacts_dir)

{'fraction_non_alphanumeric': 0.08097412480974125, 'fraction_numerical': 0.0024353120243531205, 'mean_word_length': 2.7468643101482324, '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': '625224', 'n_tokens_mistral': 921, 'n_tokens_neox': 900, 'n_words': 266}