<commit_before># Author: <NAME>, <NAME>ERN  06/2018

################################################################################
# Copyright (C) 1995-2019, <NAME> and <NAME>.                      #
# All rights reserved.                                                         #
#                                                                              #
# For the licensing terms see $ROOTSYS/LICENSE.                                #
# For the list of contributors see $ROOTSYS/README/CREDITS.                    #
################################################################################

from libROOTPythonizations import AddPrettyPrintingPyz
from ROOT import pythonization

def _add_getitem_checked(klass):
    # Parameters:
    # - klass: class where to add a __getitem__ method that raises
    # IndexError if index is out of range

    def getitem_checked(o, i):
        # Get item of `o` at `i` or raise IndexError if index is
        # out of range.
        # Assumes `o` has `__len__`.
        # Parameters:
        # - o: object
        # - i: index to be checked in object
        # Returns:
        # - o[i]
        if i >= 0 and i < len(o):
            return o._getitem__unchecked(i)
        else:
            raise IndexError('index out of range')

    klass._getitem__unchecked = klass.__getitem__
    klass.__getitem__ = getitem_checked


@pythonization()
def pythonizegeneric(klass, name):
    # Parameters:
    # klass: class to be pythonized
    # name: string containing the name of the class

    # Add pretty printing via setting the __str__ special function
    exclude = [ 'std::string' ]
    if name not in exclude:
        AddPrettyPrintingPyz(klass)

    return True<commit_msg>[PyROOT] Respect existing __str__ method in pretty printing<commit_after># Author: <NAME>, <NAME>  06/2018

################################################################################
# Copyright (C) 1995-2019, <NAME> and <NAME>.                      #
# All rights reserved.                                                         #
#                                                                              #
# For the licensing terms see $ROOTSYS/LICENSE.                                #
# For the list of contributors see $ROOTSYS/README/CREDITS.                    #
################################################################################

from libROOTPythonizations import AddPrettyPrintingPyz
from ROOT import pythonization

def _add_getitem_checked(klass):
    # Parameters:
    # - klass: class where to add a __getitem__ method that raises
    # IndexError if index is out of range

    def getitem_checked(o, i):
        # Get item of `o` at `i` or raise IndexError if index is
        # out of range.
        # Assumes `o` has `__len__`.
        # Parameters:
        # - o: object
        # - i: index to be checked in object
        # Returns:
        # - o[i]
        if i >= 0 and i < len(o):
            return o._getitem__unchecked(i)
        else:
            raise IndexError('index out of range')

    klass._getitem__unchecked = klass.__getitem__
    klass.__getitem__ = getitem_checked


@pythonization()
def pythonizegeneric(klass, name):
    # Parameters:
    # klass: class to be pythonized
    # name: string containing the name of the class

    # Add pretty printing via setting the __str__ special function

    # Exclude classes which have the method __str__ already defined in C++
    m = getattr(klass, '__str__', None)
    has_cpp_str = True if m is not None and type(m).__name__ == 'CPPOverload' else False

    # Exclude std::string with its own pythonization from cppyy
    exclude = [ 'std::string' ]

    if name not in exclude and not has_cpp_str:
        AddPrettyPrintingPyz(klass)

    return True
{'fraction_non_alphanumeric': 0.1545983086680761, 'fraction_numerical': 0.007928118393234672, 'mean_word_length': 2.084759576202119, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6440623', 'n_tokens_mistral': 992, 'n_tokens_neox': 944, 'n_words': 332}