<commit_before># cython: language_level=3
# This file is part of h5py, a Python interface to the HDF5 library.
#
# http://www.h5py.org
#
# Copyright 2008-2019 <NAME> and contributors
#
# License:  Standard 3-clause BSD; see "license.txt" for full license terms
#           and contributor agreement.

"""
    Provides access to the low-level HDF5 "H5PL" plugins interface.

    These functions are only available with HDF5 1.10.1 or later.
    They are probably not thread safe.
"""

include "config.pxi"
from .utils cimport emalloc, efree

# === C API ===================================================================

IF HDF5_VERSION >= (1, 10, 1):
    cpdef append(const char* search_path):
        """(STRING search_path)

        Add a directory to the end of the plugin search path.
        """
        H5PLappend(search_path)

    cpdef prepend(const char* search_path):
        """(STRING search_path)

        Add a directory to the start of the plugin search path.
        """
        H5PLprepend(search_path)

    cpdef replace(const char* search_path, unsigned int index):
        """(STRING search_path, UINT index)

        Replace the directory at the given index in the plugin search path.
        """
        H5PLreplace(search_path, index)

    cpdef insert(const char* search_path, unsigned int index):
        """(STRING search_path, UINT index)

        Insert a directory at the given index in the plugin search path.
        """
        H5PLinsert(search_path, index)

    cpdef remove(unsigned int index):
        """(UINT index)

        Remove the specified entry from the plugin search path.
        """
        H5PLremove(index)

    cpdef get(unsigned int index):
        """(UINT index) => STRING

        Get the directory path at the given index (starting from 0) in the
        plugin search path. Returns a Python bytes object.
        """
        cpdef size_t n
        cpdef char* buf = NULL

        n = H5PLget(index, NULL, 0)
        buf = <char*>emalloc(sizeof(char)*(n + 1))
        try:
            H5PLget(index, buf, n + 1)
            return PyBytes_FromStringAndSize(buf, n)
        finally:
            efree(buf)

    cpdef size():
        """() => UINT

        Get the number of directories currently in the plugin search path.
        """
        cpdef unsigned int n = 0
        H5PLsize(&n)
        return n
<commit_msg>Convert cpdef local variables to cdef<commit_after># cython: language_level=3
# This file is part of h5py, a Python interface to the HDF5 library.
#
# http://www.h5py.org
#
# Copyright 2008-2019 <NAME> and contributors
#
# License:  Standard 3-clause BSD; see "license.txt" for full license terms
#           and contributor agreement.

"""
    Provides access to the low-level HDF5 "H5PL" plugins interface.

    These functions are only available with HDF5 1.10.1 or later.
    They are probably not thread safe.
"""

include "config.pxi"
from .utils cimport emalloc, efree

# === C API ===================================================================

IF HDF5_VERSION >= (1, 10, 1):
    cpdef append(const char* search_path):
        """(STRING search_path)

        Add a directory to the end of the plugin search path.
        """
        H5PLappend(search_path)

    cpdef prepend(const char* search_path):
        """(STRING search_path)

        Add a directory to the start of the plugin search path.
        """
        H5PLprepend(search_path)

    cpdef replace(const char* search_path, unsigned int index):
        """(STRING search_path, UINT index)

        Replace the directory at the given index in the plugin search path.
        """
        H5PLreplace(search_path, index)

    cpdef insert(const char* search_path, unsigned int index):
        """(STRING search_path, UINT index)

        Insert a directory at the given index in the plugin search path.
        """
        H5PLinsert(search_path, index)

    cpdef remove(unsigned int index):
        """(UINT index)

        Remove the specified entry from the plugin search path.
        """
        H5PLremove(index)

    cpdef get(unsigned int index):
        """(UINT index) => STRING

        Get the directory path at the given index (starting from 0) in the
        plugin search path. Returns a Python bytes object.
        """
        cdef size_t n
        cdef char* buf = NULL

        n = H5PLget(index, NULL, 0)
        buf = <char*>emalloc(sizeof(char)*(n + 1))
        try:
            H5PLget(index, buf, n + 1)
            return PyBytes_FromStringAndSize(buf, n)
        finally:
            efree(buf)

    cpdef size():
        """() => UINT

        Get the number of directories currently in the plugin search path.
        """
        cdef unsigned int n = 0
        H5PLsize(&n)
        return n

{'fraction_non_alphanumeric': 0.11486061622301404, 'fraction_numerical': 0.015929574512680778, 'mean_word_length': 2.398860398860399, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1720587', 'n_tokens_mistral': 1400, 'n_tokens_neox': 1317, 'n_words': 505}