<commit_before>from pkg_resources import resource_string, resource_exists
import yaml
import os


def _test_filelike(parent, basename, validator):
    """
    Tests various file extension to find the requested file like resource
    :param parent: parent directory
    :param basename: portion of filename excluding the file extension
    :return: file path of the resource that exists, or None
    """
    (basename, provided_suffix) = os.path.splitext(basename)
    suffix_list = EXTENSIONS
    if not provided_suffix or provided_suffix not in suffix_list:
        suffix_list = [provided_suffix] + EXTENSIONS

    for extension in suffix_list:
        file_path = os.path.join(parent, basename + extension)
        if validator(file_path):
            return file_path

    return None


def test_resource(parent, basename, relative_to_module_name=__name__):
    resource_test = lambda file_path: resource_exists(relative_to_module_name, file_path)
    return _test_filelike(parent, basename, resource_test)

<commit_msg>This condition should only check empty strings, not None<commit_after>from pkg_resources import resource_string, resource_exists
import yaml
import os


def _test_filelike(parent, basename, validator):
    """
    Tests various file extension to find the requested file like resource
    :param parent: parent directory
    :param basename: portion of filename excluding the file extension
    :return: file path of the resource that exists, or None
    """
    (basename, provided_suffix) = os.path.splitext(basename)
    suffix_list = EXTENSIONS
    if provided_suffix == '' or provided_suffix not in suffix_list:
        suffix_list = [provided_suffix] + EXTENSIONS

    for extension in suffix_list:
        file_path = os.path.join(parent, basename + extension)
        if validator(file_path):
            return file_path

    return None


def test_resource(parent, basename, relative_to_module_name=__name__):
    resource_test = lambda file_path: resource_exists(relative_to_module_name, file_path)
    return _test_filelike(parent, basename, resource_test)


{'fraction_non_alphanumeric': 0.06163401815575729, 'fraction_numerical': 0.0, 'mean_word_length': 4.157635467980295, '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': '4532284', 'n_tokens_mistral': 605, 'n_tokens_neox': 575, 'n_words': 187}