<commit_before># -*- coding: utf-8 -*-
# Copyright (c) 2015, imageio contributors
# imageio is distributed under the terms of the (new) BSD License.

# styletest: ignore E261

""" Module imageio/freeimage.py

This module contains the wrapper code for the freeimage library.
The functions defined in this module are relatively thin; just thin
enough so that arguments and results are native Python/numpy data
types.

"""

from __future__ import absolute_import, print_function, with_statement

import os
import sys
import ctypes
import threading
import numpy

from ..core import (get_remote_file, load_lib, Dict, resource_dirs, 
                    string_types, binary_type, IS_PYPY, get_platform,
                    InternetNotAllowedError)

TEST_NUMPY_NO_STRIDES = False  # To test pypy fallback

FNAME_PER_PLATFORM = {
    'osx32': 'libfreeimage-3.16.0-osx10.6.dylib',  # universal library
    'osx64': 'libfreeimage-3.16.0-osx10.6.dylib',
    'win32': 'FreeImage-3.15.4-win32.dll',
    'win64': 'FreeImage-3.15.1-win64.dll',
    'linux32': 'libfreeimage-3.16.0-linux32.so',
    'linux64': 'libfreeimage-3.16.0-linux64.so',
}


def get_freeimage_lib():
    """ Ensure we have our version of the binary freeimage lib.
    """ 
    
    lib = os.getenv('IMAGEIO_FREEIMAGE_LIB', None)
    if lib:  # pragma: no cover
        return lib
    
    # Get filename to load
    # If we do not provide a binary, the system may still do ...
    plat = get_platform()
    if plat:
        try:
            return get_remote_file('freeimage/' + FNAME_PER_PLATFORM[plat])
        except InternetNotAllowedError:
            pass
        except RuntimeError as e:  # pragma: no cover
            print(str(e))


# Define function to encode a filename to bytes (for the current system)
efn = lambda x: x.encode(sys.getfilesystemencoding())

# 4-byte quads of 0,v,v,v from 0,0,0,0 to 0,255,255,255
GREY_PALETTE = numpy.arange(0, 0x01000000, 0x00010101, dtype=numpy.uint32)
<commit_msg>freeimage: dont error when platform is unknown<commit_after># -*- coding: utf-8 -*-
# Copyright (c) 2015, imageio contributors
# imageio is distributed under the terms of the (new) BSD License.

# styletest: ignore E261

""" Module imageio/freeimage.py

This module contains the wrapper code for the freeimage library.
The functions defined in this module are relatively thin; just thin
enough so that arguments and results are native Python/numpy data
types.

"""

from __future__ import absolute_import, print_function, with_statement

import os
import sys
import ctypes
import threading
import numpy

from ..core import (get_remote_file, load_lib, Dict, resource_dirs, 
                    string_types, binary_type, IS_PYPY, get_platform,
                    InternetNotAllowedError)

TEST_NUMPY_NO_STRIDES = False  # To test pypy fallback

FNAME_PER_PLATFORM = {
    'osx32': 'libfreeimage-3.16.0-osx10.6.dylib',  # universal library
    'osx64': 'libfreeimage-3.16.0-osx10.6.dylib',
    'win32': 'FreeImage-3.15.4-win32.dll',
    'win64': 'FreeImage-3.15.1-win64.dll',
    'linux32': 'libfreeimage-3.16.0-linux32.so',
    'linux64': 'libfreeimage-3.16.0-linux64.so',
}


def get_freeimage_lib():
    """ Ensure we have our version of the binary freeimage lib.
    """ 
    
    lib = os.getenv('IMAGEIO_FREEIMAGE_LIB', None)
    if lib:  # pragma: no cover
        return lib
    
    # Get filename to load
    # If we do not provide a binary, the system may still do ...
    plat = get_platform()
    if plat and plat in FNAME_PER_PLATFORM:
        try:
            return get_remote_file('freeimage/' + FNAME_PER_PLATFORM[plat])
        except InternetNotAllowedError:
            pass
        except RuntimeError as e:  # pragma: no cover
            print(str(e))


# Define function to encode a filename to bytes (for the current system)
efn = lambda x: x.encode(sys.getfilesystemencoding())

# 4-byte quads of 0,v,v,v from 0,0,0,0 to 0,255,255,255
GREY_PALETTE = numpy.arange(0, 0x01000000, 0x00010101, dtype=numpy.uint32)

{'fraction_non_alphanumeric': 0.1000499001996008, 'fraction_numerical': 0.04740518962075848, 'mean_word_length': 3.233368532206969, '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': '6174902', 'n_tokens_mistral': 1442, 'n_tokens_neox': 1333, 'n_words': 392}