<commit_before>from enum import Enum


class CollectionTypes(Enum):
    cache = 1
    history = 2
    item = 3


class DatabaseFactory:
    def __init__(self):
        pass

    # This is the factory method
    @staticmethod
    def get_database(collection_type, host, port, user, passwd, db, collection_name):
        if CollectionTypes.cache == collection_type:
            from cwharaj.database.cache_db import CacheDatabase
            database = CacheDatabase(host=host, port=port,
                                     user=user, passwd=<PASSWORD>,
                                     db=db, collection_name=collection_name + '_cache')
            database.open_spider()
            return database
        elif CollectionTypes.history == collection_type:
            from cwharaj.database.history_db import HistoryDatabase
            history_database = HistoryDatabase(host=host, port=port,
                                               user=user, passwd=<PASSWORD>,
                                               db=db, collection_name=collection_name + "_history")
            history_database.open_spider()
            return history_database
        elif CollectionTypes.item == collection_type:
            from cwharaj.database.item_db import ItemDatabase
            return ItemDatabase(host=host, port=port, user=user, passwd=<PASSWORD>, db=db, collection_name=collection_name)
        else:
            return None<commit_msg>charset="utf8mb4",<commit_after>from enum import Enum


class CollectionTypes(Enum):
    cache = 1
    history = 2
    item = 3


class DatabaseFactory:
    def __init__(self):
        pass

    # This is the factory method
    @staticmethod
    def get_database(collection_type, host, port, user, passwd, db, collection_name):
        if CollectionTypes.cache == collection_type:
            from cwharaj.database.cache_db import CacheDatabase
            database = CacheDatabase(host=host, port=port,
                                     user=user, passwd=<PASSWORD>,
                                     db=db, collection_name=collection_name + '_caches')
            database.open_spider()
            return database
        elif CollectionTypes.history == collection_type:
            from cwharaj.database.history_db import HistoryDatabase
            history_database = HistoryDatabase(host=host, port=port,
                                               user=user, passwd=<PASSWORD>,
                                               db=db, collection_name=collection_name + "_histories")
            history_database.open_spider()
            return history_database
        elif CollectionTypes.item == collection_type:
            from cwharaj.database.item_db import ItemDatabase
            return ItemDatabase(host=host, port=port, user=user, passwd=<PASSWORD>, db=db, collection_name=collection_name)
        else:
            return None
{'fraction_non_alphanumeric': 0.0718232044198895, 'fraction_numerical': 0.0027624309392265192, 'mean_word_length': 2.027168234064786, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1668805', 'n_tokens_mistral': 710, 'n_tokens_neox': 692, 'n_words': 167}