<commit_before>from kivy.graphics.opengl_utils cimport (gl_has_texture_native_format,
    gl_has_texture_conversion)
cimport cython
from cython cimport view as cyview
from cpython.array cimport array, clone


@cython.boundscheck(False)
@cython.wraparound(False)
cdef inline convert_to_gl_format(data, fmt):
    ''' Takes data as a bytes object or an instance that implements the python
    buffer interface. If the data format is supported by opengl, the data
    is returned unchanged. Otherwise, the data is converted to a supported
    format, when possible, and returned as a python array object.

    Note that conversion is currently only supported for bytes data.
    '''
    cdef array ret_array
    cdef char *src_buffer
    cdef char *dst_buffer
    cdef char [::1] view
    cdef int datasize
    cdef str ret_format
    cdef int i, k
    cdef char c

    # if native support of this format is available, use it
    if gl_has_texture_native_format(fmt):
        return data, fmt

    # no native support, can we at least convert it ?
    if not gl_has_texture_conversion(fmt):
        raise Exception('Unimplemented texture conversion for {}'.format(fmt))<commit_msg>img_tools.pxi: Change int -> char<commit_after>from kivy.graphics.opengl_utils cimport (gl_has_texture_native_format,
    gl_has_texture_conversion)
cimport cython
from cython cimport view as cyview
from cpython.array cimport array, clone


@cython.boundscheck(False)
@cython.wraparound(False)
cdef inline convert_to_gl_format(data, fmt):
    ''' Takes data as a bytes object or an instance that implements the python
    buffer interface. If the data format is supported by opengl, the data
    is returned unchanged. Otherwise, the data is converted to a supported
    format, when possible, and returned as a python array object.

    Note that conversion is currently only supported for bytes data.
    '''
    cdef array ret_array
    cdef char *src_buffer
    cdef char *dst_buffer
    cdef char [::1] view
    cdef int datasize
    cdef str ret_format
    cdef int i
    cdef char c, k

    # if native support of this format is available, use it
    if gl_has_texture_native_format(fmt):
        return data, fmt

    # no native support, can we at least convert it ?
    if not gl_has_texture_conversion(fmt):
        raise Exception('Unimplemented texture conversion for {}'.format(fmt))
{'fraction_non_alphanumeric': 0.05560235888795282, 'fraction_numerical': 0.0008424599831508003, 'mean_word_length': 3.6844181459566077, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '5080217', 'n_tokens_mistral': 691, 'n_tokens_neox': 680, 'n_words': 280}