<commit_before># coding:utf-8

import logging

from functools import wraps
from logging import Logger


class PropagationLogger(Logger):

    _forcing = {}
    _global_propagation_level = logging.NOTSET

    def __init__(self, name, level=logging.NOTSET, propagation=False):
        Logger.__init__(self, name, level)
        self._level_propagation = propagation

    def set_propagation(self, propagation=True):
        if isinstance(propagation, bool):
            self._level_propagation = propagation

    def getEffectiveLevel(self):
        if self.name in PropagationLogger._forcing:
            level = PropagationLogger._forcing[self.name]
            if isinstance(level, int):
                return level
            else:
                return logging.getLevelName(level)
        if PropagationLogger._global_propagation_level != logging.NOTSET:
            return PropagationLogger._global_propagation_level
        return Logger.getEffectiveLevel(self)

    @staticmethod
    def reset_level():
        PropagationLogger._global_propagation_level = logging.NOTSET

    @staticmethod
    def level_propagation(level):
        def decor(f):
            @wraps(f)
            def decorated(*args, **kwargs):
                PropagationLogger.force_level(level)
                result = f(*args, **kwargs)
                PropagationLogger.reset_level()
                return result
            return decorated
        return decor

    @staticmethod
    def force_level(*args, **kwargs):
        if len(args) > 1:
            raise TypeError("force_level() takes exactly one argument"
                            " or named arguments ({} given)".format(len(args)))

        elif len(args) == 1:
            if isinstance(args[0], int):
                PropagationLogger._global_propagation_level = args[0]
            elif isinstance(args[0], "".__class__):
                PropagationLogger._global_propagation_level = \<commit_msg>fix exception message for python 2.6<commit_after># coding:utf-8

import logging

from functools import wraps
from logging import Logger


class PropagationLogger(Logger):

    _forcing = {}
    _global_propagation_level = logging.NOTSET

    def __init__(self, name, level=logging.NOTSET, propagation=False):
        Logger.__init__(self, name, level)
        self._level_propagation = propagation

    def set_propagation(self, propagation=True):
        if isinstance(propagation, bool):
            self._level_propagation = propagation

    def getEffectiveLevel(self):
        if self.name in PropagationLogger._forcing:
            level = PropagationLogger._forcing[self.name]
            if isinstance(level, int):
                return level
            else:
                return logging.getLevelName(level)
        if PropagationLogger._global_propagation_level != logging.NOTSET:
            return PropagationLogger._global_propagation_level
        return Logger.getEffectiveLevel(self)

    @staticmethod
    def reset_level():
        PropagationLogger._global_propagation_level = logging.NOTSET

    @staticmethod
    def level_propagation(level):
        def decor(f):
            @wraps(f)
            def decorated(*args, **kwargs):
                PropagationLogger.force_level(level)
                result = f(*args, **kwargs)
                PropagationLogger.reset_level()
                return result
            return decorated
        return decor

    @staticmethod
    def force_level(*args, **kwargs):
        if len(args) > 1:
            raise TypeError("force_level() takes exactly one argument"
                            " or named arguments ({0} given)".format(len(args)))

        elif len(args) == 1:
            if isinstance(args[0], int):
                PropagationLogger._global_propagation_level = args[0]
            elif isinstance(args[0], "".__class__):
                PropagationLogger._global_propagation_level = \
{'fraction_non_alphanumeric': 0.0828658847526772, 'fraction_numerical': 0.0038245792962774095, 'mean_word_length': 2.3444160272804773, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2747567', 'n_tokens_mistral': 1038, 'n_tokens_neox': 1003, 'n_words': 230}