<commit_before># -*- coding: utf-8 -*-

from __future__ import absolute_import

import json
import logging
import os
from typing import Any, Mapping, Optional

import etcd

from eduid_common.config.parsers.base import BaseConfigParser
from eduid_common.config.parsers.decorators import decrypt, interpolate
from eduid_common.config.parsers.exceptions import ParserException

__author__ = 'lundberg'


class EtcdConfigParser(BaseConfigParser):
    def __init__(self, namespace: str, host: Optional[str] = None, port: Optional[int] = None, silent: bool = False):
        """
        :param namespace: etcd namespace to read or write, ex. /eduid/webapp/common/
        :param host: Optional etcd host
        :param port: Optional etcd port
        :param silent: set to `True` if you want silent failure for missing keys.
       """
        self.ns = namespace.lower()
        if not self.ns.startswith('/'):
            raise ParserException('Namespace {!s} has to start and end with a \"/\" character'.format(namespace))<commit_msg>correct comment about 'silent'<commit_after># -*- coding: utf-8 -*-

from __future__ import absolute_import

import json
import logging
import os
from typing import Any, Mapping, Optional

import etcd

from eduid_common.config.parsers.base import BaseConfigParser
from eduid_common.config.parsers.decorators import decrypt, interpolate
from eduid_common.config.parsers.exceptions import ParserException

__author__ = 'lundberg'


class EtcdConfigParser(BaseConfigParser):
    def __init__(self, namespace: str, host: Optional[str] = None, port: Optional[int] = None, silent: bool = False):
        """
        :param namespace: etcd namespace to read or write, ex. /eduid/webapp/common/
        :param host: Optional etcd host
        :param port: Optional etcd port
        :param silent: set to `True` if you want to silently ignore etcd errors (such as EtcdConnectionFailed).
       """
        self.ns = namespace.lower()
        if not self.ns.startswith('/'):
            raise ParserException('Namespace {!s} has to start and end with a \"/\" character'.format(namespace))
{'fraction_non_alphanumeric': 0.09568924680246328, 'fraction_numerical': 0.0009474182851729038, 'mean_word_length': 3.6417582417582417, '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': '1444756', 'n_tokens_mistral': 595, 'n_tokens_neox': 588, 'n_words': 205}