<commit_before>"""
 This module houses the ctypes initialization procedures, as well
 as the notice and error handler function callbacks (get called
 when an error occurs in GEOS).

 This module also houses GEOS Pointer utilities, including
 get_pointer_arr(), and GEOM_PTR.
"""
import atexit, os, re, sys
from ctypes import c_char_p, Structure, CDLL, CFUNCTYPE, POINTER
from ctypes.util import find_library
from django.contrib.gis.geos.error import GEOSException

# NumPy supported?
try:
    from numpy import array, ndarray
    HAS_NUMPY = True
except ImportError:
    HAS_NUMPY = False

# Custom library path set?
try:
    from django.conf import settings
    lib_path = settings.GEOS_LIBRARY_PATH
except (AttributeError, EnvironmentError, ImportError):
    lib_path = None

# Setting the appropriate names for the GEOS-C library.
if lib_path:
    lib_names = None
elif os.name == 'nt':
    # Windows NT libraries
    lib_names = ['libgeos_c-1']
elif os.name == 'posix':
    # *NIX libraries
    lib_names = ['geos_c']
else:
    raise RuntimeError('Unsupported OS "%s"' % os.name)

# Using the ctypes `find_library` utility to find the the path to the GEOS 
# shared library.  This is better than manually specifiying each library name 
# and extension (e.g., libgeos_c.[so|so.1|dylib].).
if lib_names: 
    for lib_name in lib_names:
        lib_path = find_library(lib_name)
        if not lib_path is None: break

# No GEOS library could be found.
if lib_path is None: 
    raise RuntimeError('Could not find the GEOS library (tried "%s"). '
                        'Try setting GEOS_LIBRARY_PATH in your settings.' % 
                        '", "'.join(lib_names))

# Getting the GEOS C library.  The C interface (CDLL) is used for<commit_msg>Changed [8727] to use ImportError, which seems to actually work. Not sure what I was smoking when I tested this 10 minutes ago. Refs #8680. Thanks to gkelly for cleaning up after me.<commit_after>"""
 This module houses the ctypes initialization procedures, as well
 as the notice and error handler function callbacks (get called
 when an error occurs in GEOS).

 This module also houses GEOS Pointer utilities, including
 get_pointer_arr(), and GEOM_PTR.
"""
import atexit, os, re, sys
from ctypes import c_char_p, Structure, CDLL, CFUNCTYPE, POINTER
from ctypes.util import find_library
from django.contrib.gis.geos.error import GEOSException

# NumPy supported?
try:
    from numpy import array, ndarray
    HAS_NUMPY = True
except ImportError:
    HAS_NUMPY = False

# Custom library path set?
try:
    from django.conf import settings
    lib_path = settings.GEOS_LIBRARY_PATH
except (AttributeError, EnvironmentError, ImportError):
    lib_path = None

# Setting the appropriate names for the GEOS-C library.
if lib_path:
    lib_names = None
elif os.name == 'nt':
    # Windows NT libraries
    lib_names = ['libgeos_c-1']
elif os.name == 'posix':
    # *NIX libraries
    lib_names = ['geos_c']
else:
    raise ImportError('Unsupported OS "%s"' % os.name)

# Using the ctypes `find_library` utility to find the the path to the GEOS 
# shared library.  This is better than manually specifiying each library name 
# and extension (e.g., libgeos_c.[so|so.1|dylib].).
if lib_names: 
    for lib_name in lib_names:
        lib_path = find_library(lib_name)
        if not lib_path is None: break

# No GEOS library could be found.
if lib_path is None: 
    raise ImportError('Could not find the GEOS library (tried "%s"). '
                        'Try setting GEOS_LIBRARY_PATH in your settings.' % 
                        '", "'.join(lib_names))

# Getting the GEOS C library.  The C interface (CDLL) is used for
{'fraction_non_alphanumeric': 0.08067593349686564, 'fraction_numerical': 0.0038157536113382394, 'mean_word_length': 3.470158343483557, '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': '1192106', 'n_tokens_mistral': 1158, 'n_tokens_neox': 1102, 'n_words': 435}