<commit_before>from enum import Enum
from functools import wraps, partial
from mock import MagicMock

from nameko.extensions import DependencyProvider
from statsd import StatsClient, TCPStatsClient


class Protocols(Enum):
    tcp = 'tcp'
    udp = 'udp'


class LazyClient(object):

    """Provide an interface to `StatsClient` with a lazy client creation.
    """

    def __init__(self, **config):
        self.config = config
        self.enabled = config.pop('enabled')
        self._client = None

        protocol = self.config.pop('protocol', 'udp')

        try:
            self.protocol = getattr(Protocols, protocol.lower())
        except AttributeError:
            raise ValueError(<commit_msg>FR-996-FR-1301: Improve handling of default protocol<commit_after>from enum import Enum
from functools import wraps, partial
from mock import MagicMock

from nameko.extensions import DependencyProvider
from statsd import StatsClient, TCPStatsClient


class Protocols(Enum):
    tcp = 'tcp'
    udp = 'udp'


class LazyClient(object):

    """Provide an interface to `StatsClient` with a lazy client creation.
    """

    def __init__(self, **config):
        self.config = config
        self.enabled = config.pop('enabled')
        self._client = None

        protocol = self.config.pop('protocol', Protocols.udp.name)

        try:
            self.protocol = getattr(Protocols, protocol.lower())
        except AttributeError:
            raise ValueError(
{'fraction_non_alphanumeric': 0.09115646258503401, 'fraction_numerical': 0.004761904761904762, 'mean_word_length': 3.008174386920981, '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': '5496092', 'n_tokens_mistral': 415, 'n_tokens_neox': 391, 'n_words': 124}