<commit_before>import os
import subprocess
import tempfile

from irctest.basecontrollers import BaseClientController, NotImplementedByController

TEMPLATE_CONFIG = """
[core]
nick = Sopel
host = {hostname}
use_ssl = false
port = {port}
owner = me
channels =
timeout = 5
auth_username = {username}
auth_password = {password}
{auth_method}
"""


class SopelController(BaseClientController):
    software_name = "Sopel"
    supported_sasl_mechanisms = {"PLAIN"}
    supported_capabilities = set()  # Not exhaustive

    def __init__(self, test_config):
        super().__init__(test_config)
        self.filename = next(tempfile._get_candidate_names()) + ".cfg"
        self.proc = None

    def kill(self):
        if self.proc:
            self.proc.kill()
        if self.filename:
            try:
                os.unlink(os.path.join(os.path.expanduser("~/.sopel/"), self.filename))
            except OSError:  #  File does not exist
                pass

    def open_file(self, filename, mode="a"):
        return open(os.path.join(os.path.expanduser("~/.sopel/"), filename), mode)

    def create_config(self):
        with self.open_file(self.filename):
            pass<commit_msg>sopel: Create ~/.sopel/ if it does not exist<commit_after>import os
import subprocess
import tempfile

from irctest.basecontrollers import BaseClientController, NotImplementedByController

TEMPLATE_CONFIG = """
[core]
nick = Sopel
host = {hostname}
use_ssl = false
port = {port}
owner = me
channels =
timeout = 5
auth_username = {username}
auth_password = {password}
{auth_method}
"""


class SopelController(BaseClientController):
    software_name = "Sopel"
    supported_sasl_mechanisms = {"PLAIN"}
    supported_capabilities = set()  # Not exhaustive

    def __init__(self, test_config):
        super().__init__(test_config)
        self.filename = next(tempfile._get_candidate_names()) + ".cfg"
        self.proc = None

    def kill(self):
        if self.proc:
            self.proc.kill()
        if self.filename:
            try:
                os.unlink(os.path.join(os.path.expanduser("~/.sopel/"), self.filename))
            except OSError:  #  File does not exist
                pass

    def open_file(self, filename, mode="a"):
        dir_path = os.path.expanduser("~/.sopel/")
        os.makedirs(dir_path, exist_ok=True)
        return open(os.path.join(dir_path, filename), mode)

    def create_config(self):
        with self.open_file(self.filename):
            pass
{'fraction_non_alphanumeric': 0.11464199517296862, 'fraction_numerical': 0.0008045052292839903, 'mean_word_length': 2.904238618524333, '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': '5497522', 'n_tokens_mistral': 794, 'n_tokens_neox': 777, 'n_words': 170}