<commit_before># -*- coding: utf-8 -*-

########################################################################
#
# License: BSD
# Created: October 1, 2002
# Author: <NAME> - <EMAIL>
#
# $Id$
#
########################################################################

"""PyTables, hierarchical datasets in Python.

:URL: http://www.pytables.org/

PyTables is a package for managing hierarchical datasets and designed
to efficiently cope with extremely large amounts of data.

"""


import os
import sys


# On Windows, pre-load the HDF5 DLLs into the process via Ctypes
# to improve diagnostics and avoid issues when loading DLLs during runtime.
# However, if running from a frozen app (via PyInstaller), skip the check.
if os.name == 'nt' and not getattr(sys, 'frozen', False):
    import ctypes

    def _load_library(dllname, loadfunction, dllpaths=('', )):
        """Load a DLL via ctypes load function. Return None on failure.

        By default, try to load the DLL from the current package
        directory first, then from the Windows DLL search path.

        """
        try:
            dllpaths = (os.path.abspath(
                os.path.dirname(__file__)), ) + dllpaths
        except NameError:
            pass  # PyPy and frozen distributions have no __file__ attribute
        for path in dllpaths:
            if path:
                # Temporarily add the path to the PATH environment variable
                # so Windows can find additional DLL dependencies.
                try:
                    oldenv = os.environ['PATH']
                    os.environ['PATH'] = path + ';' + oldenv
                except KeyError:
                    oldenv = None
            try:
                return loadfunction(os.path.join(path, dllname))
            except WindowsError:
                pass
            finally:
                if path and oldenv is not None:
                    os.environ['PATH'] = oldenv
        return None

    # In order to improve diagnosis of a common Windows dependency
    # issue, we explicitly test that we can load the HDF5 dll before
    # loading tables.utilsextensions.
    import sys
    hdf5_dlls = ['hdf5.dll', 'hdf5dll.dll']
    if hasattr(sys, 'gettotalrefcount'):  # running with debug interpreter
        hdf5_dlls = ['hdf5_D.dll', 'hdf5ddll.dll']
    for dll in hdf5_dlls:
        if _load_library(dll, ctypes.cdll.LoadLibrary):
            break
    else:
        raise ImportError(
            'Could not load any of %s, please ensure'
            ' that it can be found in the system path' % hdf5_dlls)<commit_msg>WIN: Py3.8 DLL resolution fix<commit_after># -*- coding: utf-8 -*-

########################################################################
#
# License: BSD
# Created: October 1, 2002
# Author: <NAME> - <EMAIL>
#
# $Id$
#
########################################################################

"""PyTables, hierarchical datasets in Python.

:URL: http://www.pytables.org/

PyTables is a package for managing hierarchical datasets and designed
to efficiently cope with extremely large amounts of data.

"""


import os
import sys


# On Windows, pre-load the HDF5 DLLs into the process via Ctypes
# to improve diagnostics and avoid issues when loading DLLs during runtime.
# However, if running from a frozen app (via PyInstaller), skip the check.
if os.name == 'nt' and not getattr(sys, 'frozen', False):
    import ctypes

    def _load_library(dllname, loadfunction, dllpaths=('', )):
        """Load a DLL via ctypes load function. Return None on failure.

        By default, try to load the DLL from the current package
        directory first, then from the Windows DLL search path.

        Python >= 3.8 no longer searches PATH for DLLs. Skip PATH modification
        on Python >= 3.8.

        """
        try:
            dllpaths = (os.path.abspath(
                os.path.dirname(__file__)), ) + dllpaths
        except NameError:
            pass  # PyPy and frozen distributions have no __file__ attribute
        oldenv = None
        for path in dllpaths:
            if path and sys.version_info < (3, 8):
                # Temporarily add the path to the PATH environment variable
                # so Windows can find additional DLL dependencies.
                try:
                    oldenv = os.environ['PATH']
                    os.environ['PATH'] = path + ';' + oldenv
                except KeyError:
                    oldenv = None
            try:
                return loadfunction(os.path.join(path, dllname))
            except WindowsError:
                pass
            finally:
                if path and oldenv is not None:
                    os.environ['PATH'] = oldenv
        return None

    # In order to improve diagnosis of a common Windows dependency
    # issue, we explicitly test that we can load the HDF5 dll before
    # loading tables.utilsextensions.
    import sys
    hdf5_dlls = ['hdf5.dll', 'hdf5dll.dll']
    if hasattr(sys, 'gettotalrefcount'):  # running with debug interpreter
        hdf5_dlls = ['hdf5_D.dll', 'hdf5ddll.dll']
    for dll in hdf5_dlls:
        if _load_library(dll, ctypes.cdll.LoadLibrary):
            break
    else:
        if sys.version_info < (3, 8):
            dll_loc = 'can be found in the system path'
        else:
            dll_loc = 'is installed in the package folder'
        raise ImportError(
            'Could not load any of %s, please ensure that it %s.' % (hdf5_dlls, dll_loc))
{'fraction_non_alphanumeric': 0.13141084139441503, 'fraction_numerical': 0.00766563241467421, 'mean_word_length': 2.2368576491435324, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '722976', 'n_tokens_mistral': 1555, 'n_tokens_neox': 1443, 'n_words': 552}