<commit_before>import os
import shutil

import moban.reporter as reporter
from moban.hashstore import HASH_STORE


class Copier(object):

    def __init__(self, template_dirs):
        self.template_dirs = template_dirs
        self._count = 0

    def copy_files(self, file_list):
        for dest_src_pair in file_list:
            for dest, src in dest_src_pair.items():
                src_path = self._get_src_file(src)
                if src_path:
                    if HASH_STORE.are_two_file_different(src_path, dest):
                        reporter.report_copying(src_path, dest)
                        shutil.copy(src_path, dest)
                        self._count = self._count + 1
                else:
                    reporter.report_error_message(
                        "{0} cannot be found".format(src)
                    )

    def number_of_copied_files(self):
        return self._count

    def report(self):
        if self._count:
            reporter.report_copying_summary(self._count)
        else:
            reporter.report_no_copying()

    def _get_src_file(self, src):
        for folder in self.template_dirs:
            path = os.path.join(folder, src)
            if os.path.exists(path):
                return path
        else:
            return None<commit_msg>:hammer: code refactoring<commit_after>import os
import shutil

import moban.reporter as reporter
from moban.hashstore import HASH_STORE


class Copier(object):

    def __init__(self, template_dirs):
        self.template_dirs = template_dirs
        self._count = 0

    def copy_files(self, file_list):
        for dest_src_pair in file_list:
            for dest, src in dest_src_pair.items():
                src_path = self._get_src_file(src)
                if src_path is None:
                    reporter.report_error_message(
                        "{0} cannot be found".format(src)
                    )
                elif HASH_STORE.are_two_file_different(src_path, dest):
                    reporter.report_copying(src_path, dest)
                    shutil.copy(src_path, dest)
                    self._count = self._count + 1

    def number_of_copied_files(self):
        return self._count

    def report(self):
        if self._count:
            reporter.report_copying_summary(self._count)
        else:
            reporter.report_no_copying()

    def _get_src_file(self, src):
        for folder in self.template_dirs:
            path = os.path.join(folder, src)
            if os.path.exists(path):
                return path
        else:
            return None
{'fraction_non_alphanumeric': 0.07246932515337423, 'fraction_numerical': 0.0023006134969325155, 'mean_word_length': 1.7177083333333334, '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': '6489636', 'n_tokens_mistral': 766, 'n_tokens_neox': 735, 'n_words': 166}