<commit_before>import os
import subprocess
from approvaltests.Reporter import Reporter


class TextDiffReporter(Reporter):
    DIFF_TOOL_ENVIRONMENT_VARIABLE_NAME = 'APPROVALS_TEXT_DIFF_TOOL'

    @staticmethod
    def run_command(command_array):
        subprocess.call(command_array)

    @classmethod
    def get_command(cls, approved_path, received_path):
        diff_tool = os.environ[cls.DIFF_TOOL_ENVIRONMENT_VARIABLE_NAME]
        return [diff_tool, received_path, approved_path]

    def report(self, approved_path, received_path):
        if not os.path.isfile(approved_path):
            open(approved_path, 'w').close()
        command_array = self.get_command(approved_path, received_path)
        self.run_command(command_array)

<commit_msg>Extract method so that creation of file is more obvious.<commit_after>import os
import subprocess
from approvaltests.Reporter import Reporter


class TextDiffReporter(Reporter):
    DIFF_TOOL_ENVIRONMENT_VARIABLE_NAME = 'APPROVALS_TEXT_DIFF_TOOL'

    @staticmethod
    def run_command(command_array):
        subprocess.call(command_array)

    @staticmethod
    def create_empty_file(file_path):
        open(file_path, 'w').close()

    @classmethod
    def get_command(cls, approved_path, received_path):
        diff_tool = os.environ[cls.DIFF_TOOL_ENVIRONMENT_VARIABLE_NAME]
        return [diff_tool, received_path, approved_path]

    def report(self, approved_path, received_path):
        if not os.path.isfile(approved_path):
            self.create_empty_file(approved_path)
        command_array = self.get_command(approved_path, received_path)
        self.run_command(command_array)


{'fraction_non_alphanumeric': 0.0748792270531401, 'fraction_numerical': 0.0, 'mean_word_length': 4.2271293375394325, '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': '6064445', 'n_tokens_mistral': 535, 'n_tokens_neox': 513, 'n_words': 93}