<commit_before># -*- test-case-name: vumi.persist.tests.test_txredis_manager -*-

import txredis.protocol
from twisted.internet import reactor
from twisted.internet.defer import inlineCallbacks, DeferredList, succeed

from vumi.persist.redis_base import Manager
from vumi.persist.fake_redis import FakeRedis


class TxRedisManager(Manager):
    @classmethod
    def _fake_manager(cls, key_prefix, client=None):
        if client is None:
            client = FakeRedis(async=True)
        manager = cls(client, key_prefix)
        # Because ._close() assumes a real connection.
        manager._close = client.teardown
        return succeed(manager)

    @classmethod
    def _manager_from_config(cls, config, key_prefix):
        """Construct a manager from a dictionary of options.<commit_msg>Add call_decorator to TxRedisManager.<commit_after># -*- test-case-name: vumi.persist.tests.test_txredis_manager -*-

import txredis.protocol
from twisted.internet import reactor
from twisted.internet.defer import inlineCallbacks, DeferredList, succeed

from vumi.persist.redis_base import Manager
from vumi.persist.fake_redis import FakeRedis


class TxRedisManager(Manager):

    call_decorator = staticmethod(inlineCallbacks)

    @classmethod
    def _fake_manager(cls, key_prefix, client=None):
        if client is None:
            client = FakeRedis(async=True)
        manager = cls(client, key_prefix)
        # Because ._close() assumes a real connection.
        manager._close = client.teardown
        return succeed(manager)

    @classmethod
    def _manager_from_config(cls, config, key_prefix):
        """Construct a manager from a dictionary of options.
{'fraction_non_alphanumeric': 0.08028759736369083, 'fraction_numerical': 0.0, 'mean_word_length': 3.7175141242937855, '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': '7127127', 'n_tokens_mistral': 492, 'n_tokens_neox': 485, 'n_words': 128}