<commit_before>from devilry.devilry_ziputil.backends.backends_base import PythonZipFileBackend

from django.conf import settings


class MockDevilryZipBackend(PythonZipFileBackend):
    """

    """
    backend_id = 'default'

    @classmethod
    def get_storage_location(cls):
        return settings.DEVILRY_GROUP_ZIPFILE_DIRECTORY

    def __init__(self, **kwargs):
        super(MockDevilryZipBackend, self).__init__(**kwargs)


class MockDevilryZipBackendS3(MockDevilryZipBackend):
    """

    """
    backend_id = 's3'

    @classmethod
    def get_storage_location(cls):
        return 'url/to/s3/filestorage'

    def __init__(self, **kwargs):
        super(MockDevilryZipBackendS3, self).__init__(**kwargs)


class MockDevilryZipBackendHeroku(MockDevilryZipBackend):
    """

    """
    backend_id = 'heroku'

    @classmethod
    def get_storage_location(cls):
        return 'url/to/heroku/filestorage'

    def __init__(self, **kwargs):
        super(MockDevilryZipBackendHeroku, self).__init__(**kwargs)
<commit_msg>devilry_ziputil/backends: Mockbackend(used for testing) creates specified folder path.<commit_after>from devilry.devilry_ziputil.backends.backends_base import PythonZipFileBackend

from django.conf import settings

import os


class MockDevilryZipBackend(PythonZipFileBackend):
    """
    Used for testing.
    """
    backend_id = 'default'

    @classmethod
    def get_storage_location(cls):
        return settings.DEVILRY_GROUP_ZIPFILE_DIRECTORY

    def __init__(self, **kwargs):
        super(MockDevilryZipBackend, self).__init__(**kwargs)
        self.__create_path_if_not_exists()

    def __create_path_if_not_exists(self):
        """
        Create path if given path does not exist.
        """
        if os.path.exists(self.archive_path):
            return
        path_list = self.archive_path.split('/')
        path_list.pop()
        pathbuilder = ''
        for path in path_list:
            pathbuilder += path + '/'
            if not os.path.exists(pathbuilder):
                os.mkdir(pathbuilder)


class MockDevilryZipBackendS3(MockDevilryZipBackend):
    """

    """
    backend_id = 's3'

    @classmethod
    def get_storage_location(cls):
        return 'url/to/s3/filestorage'

    def __init__(self, **kwargs):
        super(MockDevilryZipBackendS3, self).__init__(**kwargs)


class MockDevilryZipBackendHeroku(MockDevilryZipBackend):
    """

    """
    backend_id = 'heroku'

    @classmethod
    def get_storage_location(cls):
        return 'url/to/heroku/filestorage'

    def __init__(self, **kwargs):
        super(MockDevilryZipBackendHeroku, self).__init__(**kwargs)

{'fraction_non_alphanumeric': 0.10196374622356495, 'fraction_numerical': 0.0030211480362537764, 'mean_word_length': 3.300324675324675, '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': '4547856', 'n_tokens_mistral': 873, 'n_tokens_neox': 842, 'n_words': 140}