<commit_before>from webapp_health_monitor import errors


class Verificator(object):
    verificator_name = None

    def __init__(self, **kwargs):
        pass

    def run(self):
        raise NotImplementedError()

    def __str__(self):
        if self.verificator_name:
            return self.verificator_name
        else:
            return self.__class__.__name__


class RangeVerificator(Verificator):
    upper_bound = None
    lower_bound = None

    def run(self):
        range_checker = self._validate_range()
        range_checker.check(self.get_value())

    def _validate_range(self):
        if self.lower_bound is None:
            if self.upper_bound is None:
                raise errors.BadConfigurationError()
            else:
                return UpperBoundChecker(self.upper_bound)
        else:
            if self.upper_bound is None:
                return LowerBoundChecker(self.lower_bound)
            else:
                if self.lower_bound < self.upper_bound:
                    return RangeChecker(self.lower_bound, self.upper_bound)
                else:
                    raise errors.BadConfigurationError()

    def get_value(self):
        raise NotImplementedError


class RangeCheckerBase:
    def check(self, value):
        raise NotImplementedError


class RangeChecker(RangeCheckerBase):
    def __init__(self, lower_bound, upper_bound):<commit_msg>Allow overwriting methods for configuring range for range verificator.<commit_after>from webapp_health_monitor import errors


class Verificator(object):
    verificator_name = None

    def __init__(self, **kwargs):
        pass

    def run(self):
        raise NotImplementedError()

    def __str__(self):
        if self.verificator_name:
            return self.verificator_name
        else:
            return self.__class__.__name__


class RangeVerificator(Verificator):
    upper_bound = None
    lower_bound = None

    def run(self):
        range_checker = self._validate_range()
        range_checker.check(self.get_value())

    def _validate_range(self):
        lower_bound = self.get_lower_bound()
        upper_bound = self.get_upper_bound()

        if lower_bound is None:
            if upper_bound is None:
                raise errors.BadConfigurationError()
            else:
                return UpperBoundChecker(upper_bound)
        else:
            if upper_bound is None:
                return LowerBoundChecker(lower_bound)
            else:
                if lower_bound < upper_bound:
                    return RangeChecker(lower_bound, upper_bound)
                else:
                    raise errors.BadConfigurationError()

    def get_lower_bound(self):
        return self.lower_bound

    def get_upper_bound(self):
        return self.upper_bound

    def get_value(self):
        raise NotImplementedError


class RangeCheckerBase:
    def check(self, value):
        raise NotImplementedError


class RangeChecker(RangeCheckerBase):
    def __init__(self, lower_bound, upper_bound):
{'fraction_non_alphanumeric': 0.06519591702337833, 'fraction_numerical': 0.0, 'mean_word_length': 2.2457264957264957, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2355872', 'n_tokens_mistral': 836, 'n_tokens_neox': 810, 'n_words': 189}