<commit_before>__all__ = [
    'FrameError', 'FrameNotFound', 'FrameType', 'Frame',
    'current_frame', 'locate_frame'
]


import sys

if not hasattr(sys, '_getframe'):
    try:
        raise
    except:
        traceback = sys.exc_info()[2]

        if (not hasattr(traceback, 'tb_frame') or
            not hasattr(traceback.tb_frame, 'f_back')):
            raise ImportError(
                'Unable to capture frames. sys._getframe() is not supported in '
                'this Python implementation, and the traceback object does not '
                'conform to CPython specifications.')
    finally:
        del traceback
        sys.exc_clear()

def _getframe(level=0):
    '''
    A reimplementation of `sys._getframe()`, which is a private function,
    and isn't guaranteed to exist in all versions and implementations of
    Python. This function is about 2x slower. `sys.exc_info()` only
    returns helpful information if an exception has been raised.

    :param level:
        The number of levels deep in the stack to return the frame from.
        Defaults to `0`.
    :returns:
        A frame object `levels` deep from the top of the stack.
    '''

    try:
        raise
    except:
        # sys.exc_info() returns (type, value, traceback).
        frame = sys.exc_info()[2].tb_frame

        for i in xrange(0, level + 1): # + 1 to account for our exception.
            frame = frame.f_back
    finally:
        sys.exc_clear()

    return frame


# Make classes new-style by default.
__metaclass__ = type


class Frame:
    '''
    Wrapper object for the internal frames.
    '''

    NATIVE = hasattr(sys, '_getframe')

    class Error(Exception):
        '''
        The base for everything frame related going wrong in the module.
        '''

    class NotFound(Error, LookupError):
        '''
        Raised when no frame is found.
        '''

    Type = sys._getframe().__class__

    @staticmethod
    def current_frame(raw=False):
        '''
        Gives the current execution frame.

        :returns: The current execution frame that is actually executing this.
        '''

        # `import sys` is important here, because the `sys` module is special
        # and we will end up with the class frame instead of the `current` one.

        frame = __import__('sys')._getframe().f_back if Frame.NATIVE else Frame._getframe().f_back

        if not raw:
            frame = Frame(frame)

        return frame<commit_msg>Fixing style.<commit_after>__all__ = [
    'FrameError', 'FrameNotFound', 'FrameType', 'Frame',
    'current_frame', 'locate_frame'
]


import sys

if not hasattr(sys, '_getframe'):
    try:
        raise
    except:
        traceback = sys.exc_info()[2]

        if (not hasattr(traceback, 'tb_frame') or
            not hasattr(traceback.tb_frame, 'f_back')):
            raise ImportError(
                'Unable to capture frames. sys._getframe() is not supported in '
                'this Python implementation, and the traceback object does not '
                'conform to CPython specifications.')
    finally:
        del traceback
        sys.exc_clear()

def _getframe(level=0):
    '''
    A reimplementation of `sys._getframe()`, which is a private function,
    and isn't guaranteed to exist in all versions and implementations of
    Python. This function is about 2x slower. `sys.exc_info()` only
    returns helpful information if an exception has been raised.

    :param level:
        The number of levels deep in the stack to return the frame from.
        Defaults to `0`.
    :returns:
        A frame object `levels` deep from the top of the stack.
    '''

    try:
        raise
    except:
        # sys.exc_info() returns (type, value, traceback).
        frame = sys.exc_info()[2].tb_frame

        for i in xrange(0, level + 1): # + 1 to account for our exception.
            frame = frame.f_back
    finally:
        sys.exc_clear()

    return frame


# Make classes new-style by default.
__metaclass__ = type


class Frame:
    '''
    Wrapper object for the internal frames.
    '''

    NATIVE = hasattr(sys, '_getframe')

    class Error(Exception):
        '''
        The base for everything frame related going wrong in the module.
        '''

    class NotFound(Error, LookupError):
        '''
        Raised when no frame is found.
        '''

    Type = sys._getframe().__class__

    @staticmethod
    def current_frame(raw=False):
        '''
        Gives the current execution frame.

        :returns: The current execution frame that is actually executing this.
        '''

        # `import sys` is important here, because the `sys` module is special
        # and we will end up with the class frame instead of the `current` one.

        frame = (__import__('sys')._getframe() if Frame.NATIVE else _getframe()).f_back

        if not raw:
            frame = Frame(frame)

        return frame
{'fraction_non_alphanumeric': 0.09175991861648017, 'fraction_numerical': 0.0032553407934893183, 'mean_word_length': 2.223606557377049, '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': '1106723', 'n_tokens_mistral': 1405, 'n_tokens_neox': 1338, 'n_words': 500}