<commit_before>import contextlib
import sys


def check_verbosity(old_fn):
    """
    Checks that the provided verbosity argument is less than or equal to the
    current verbosity level before executing the decorated method.  If this
    check fails, the method is not executed.
    """
    def new_fn(self, *args, **kwargs):
        verbosity = kwargs.pop('verbosity', 0)
        if verbosity <= self._verbosity:
            old_fn(self, *args, **kwargs)
    return new_fn


class StandardStreams(object):
    """
    Class to facilitate writing of log messages to standard streams.
    """
    def __init__(self):
        self._verbosity = 0

    @check_verbosity
    def err(self, msg, newline=True):
        """
        Prints the given message to stderr, including a newline by default.

        Examples:
        >>> err('Test')
        Test
        >>> err('Test', newline=False)
        Test>>>
        """
        sys.stderr.write(msg + ('\n' if newline else ''))

    @check_verbosity
    def bar(self, msg='', width=70, position=None, stream=sys.stderr):
        """
        Prints a bar text effect to the standard stream specified by `stream`.

        Examples:
        >>> bar('test', width=10)
        == test ==
        >>> bar(width=10)
        ==========
        >>> bar('<NAME> is...', position='top')
        //========= <NAME> is... ========\\\\
        >>> bar('...MacGyver', position='bottom')
        \\\\================= ...MacGyver ================//
        """
        width = max(width, len(msg) + 4)

        if msg:
            bar_len = width - len(msg) - 2
        else:
            bar_len = width<commit_msg>Update bar to facilitate testing<commit_after>import contextlib
import sys


def check_verbosity(old_fn):
    """
    Checks that the provided verbosity argument is less than or equal to the
    current verbosity level before executing the decorated method.  If this
    check fails, the method is not executed.
    """
    def new_fn(self, *args, **kwargs):
        verbosity = kwargs.pop('verbosity', 0)
        if verbosity <= self._verbosity:
            old_fn(self, *args, **kwargs)
    return new_fn


class StandardStreams(object):
    """
    Class to facilitate writing of log messages to standard streams.
    """
    def __init__(self):
        self._verbosity = 0

    @check_verbosity
    def err(self, msg, newline=True):
        """
        Prints the given message to stderr, including a newline by default.

        Examples:
        >>> err('Test')
        Test
        >>> err('Test', newline=False)
        Test>>>
        """
        sys.stderr.write(msg + ('\n' if newline else ''))

    @check_verbosity
    def bar(self, msg='', width=70, position=None, stream=None):
        """
        Prints a bar text effect to the standard stream specified by `stream`.

        Examples:
        >>> bar('test', width=10)
        == test ==
        >>> bar(width=10)
        ==========
        >>> bar('<NAME> is...', position='top')
        //========= <NAME> is... ========\\\\
        >>> bar('...MacGyver', position='bottom')
        \\\\================= ...MacGyver ================//
        """
        width = max(width, len(msg) + 4)
        # Must set this here as opposed to in the argument list so mock tests
        # will work
        stream = stream or sys.stderr

        if msg:
            bar_len = width - len(msg) - 2
        else:
            bar_len = width
{'fraction_non_alphanumeric': 0.15887307580598314, 'fraction_numerical': 0.005808887598024978, 'mean_word_length': 2.097122302158273, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 49, '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': '7215897', 'n_tokens_mistral': 998, 'n_tokens_neox': 947, 'n_words': 301}