<commit_before>from pathlib import Path
import shutil

from webdriver_controller import config
from webdriver_controller.drivers.chromedriver import ChromeDriver
from webdriver_controller.drivers.selenium_standalone import SeleniumStandalone


class WebdriverController(object):
    _installation_folder = Path('{}{}'.format(Path.cwd(),
                                              config.INSTALLATION_FOLDER))

    def download(self):
        if not self._installation_folder.exists():
            self._installation_folder.mkdir()

        chromedriver = ChromeDriver()
        chromedriver.download_driver()

        selenium_standalone = SeleniumStandalone()
        selenium_standalone.download_driver()

    def cleanup(self):
        if self._installation_folder.exists():
            print('deleting {} ...'.format(self._installation_folder))
            shutil.rmtree(self._installation_folder)
        else:
            print('no Selenium Webdriver installation found')<commit_msg>write downloaded Selenium Webdriver version to file<commit_after>import json
from pathlib import Path
import shutil

from webdriver_controller import config
from webdriver_controller.drivers.chromedriver import ChromeDriver
from webdriver_controller.drivers.selenium_standalone import SeleniumStandalone


class WebdriverController(object):
    __installation_folder = Path('{}{}'.format(Path.cwd(),
                                               config.INSTALLATION_FOLDER))
    __installation_file = Path('{}{}/{}'.format(Path.cwd(),
                                                config.INSTALLATION_FOLDER,
                                                config.INSTALLATION_FILE))
    __outdated_file = Path('{}.old'.format(__installation_file))

    def __check_installation_file(self):
        if self.__installation_file.exists():
            self.__installation_file.rename(self.__outdated_file)

    def __remove_outdated_installation_file(self):
        if self.__outdated_file.exists():
            self.__outdated_file.unlink()

    def download(self):
        if not self.__installation_folder.exists():
            self.__installation_folder.mkdir()

        self.__check_installation_file()

        chromedriver = ChromeDriver()
        chromedriver.download_driver()

        selenium_standalone = SeleniumStandalone()
        selenium_standalone.download_driver()

        versions = {
            'chrome': chromedriver.version,
            'selenium': selenium_standalone.version
        }

        with open(self.__installation_file, 'w') as fh:
            json.dump(versions, fh)

        self.__remove_outdated_installation_file()

    def cleanup(self):
        if self.__installation_folder.exists():
            print('deleting {} ...'.format(self.__installation_folder))
            shutil.rmtree(self.__installation_folder)
        else:
            print('no Selenium Webdriver installation found')
{'fraction_non_alphanumeric': 0.08521560574948665, 'fraction_numerical': 0.0, 'mean_word_length': 2.7235668789808916, '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': 15, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1865316', 'n_tokens_mistral': 776, 'n_tokens_neox': 735, 'n_words': 133}