<commit_before>"""A configuration management class built on top of etcd

See:  http://python-etcd.readthedocs.org/

It provides a read-only access and just exposes a nested dict
"""
import functools
import etcd
import time
from conman.conman_base import ConManBase


def thrice(delay=0.5):
    """This decorator tries failed operations 3 times before it gives up

    The delay determines how long to wait between tries (in seconds)
    """
    def decorated(f):
        @functools.wraps(f)
        def wrapped(*args, **kwargs):
            for i in xrange(3):
                try:
                    return f(*args, **kwargs)
                except Exception:
                    if i == 3:
                        raise
                    time.sleep(delay)
        return wrapped
    return decorated


class ConManEtcd(ConManBase):
    def __init__(self, host='127.0.0.1', port=4001, allow_reconnect=True):
        ConManBase.__init__(self)
        self._connect(host, port, allow_reconnect)<commit_msg>fix thrice<commit_after>"""A configuration management class built on top of etcd

See:  http://python-etcd.readthedocs.org/

It provides a read-only access and just exposes a nested dict
"""
import functools
import etcd
import time
from conman.conman_base import ConManBase


def thrice(delay=0.5):
    """This decorator tries failed operations 3 times before it gives up

    The delay determines how long to wait between tries (in seconds)
    """
    def decorated(f):
        @functools.wraps(f)
        def wrapped(*args, **kwargs):
            for i in xrange(3):
                try:
                    return f(*args, **kwargs)
                except Exception:
                    if i == 2:
                        raise
                    time.sleep(delay)
        return wrapped
    return decorated


class ConManEtcd(ConManBase):
    def __init__(self, host='127.0.0.1', port=4001, allow_reconnect=True):
        ConManBase.__init__(self)
        self._connect(host, port, allow_reconnect)
{'fraction_non_alphanumeric': 0.08743169398907104, 'fraction_numerical': 0.014903129657228018, 'mean_word_length': 2.237942122186495, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '2446329', 'n_tokens_mistral': 591, 'n_tokens_neox': 555, 'n_words': 184}