<commit_before>from __future__ import absolute_import, print_function

import sys

# Selective Import here to allow extending the import logic with other py2.7 importers
if (2, 7) <= sys.version_info < (3, 4):  # TODO : test : valid until which py3 version ?
    from ._filefinder2 import get_supported_ns_loaders, PathFinder2, NamespaceMetaFinder2, FileFinder2
    from ._fileloader2 import NamespaceLoader2, Loader2, SourceFileLoader2, ImpLoader


# Making the activation explicit for now
def activate():
    """Install the path-based import components."""
    if (2, 7) <= sys.version_info < (3, 4):  # TODO : test : valid until which py3 version ?
        supported_loaders = get_supported_ns_loaders()
        ns_hook = FileFinder2.path_hook(*supported_loaders)
        ##### Note this must be early in the list, since we change the logic regarding what is a package or not
        #sys.path_hooks.insert(1, ns_hook)
        sys.path_hooks.append(ns_hook)
        # Resetting sys.path_importer_cache values,
        # to support the case where we have an implicit package inside an already loaded package,
        # since we need to replace the default importer.
        sys.path_importer_cache.clear()

        # Setting up the meta_path to change package finding logic
        sys.meta_path.append(NamespaceMetaFinder2)

    else:
        # Useful to avoid traps since logic is different with finder and loader on python3
        raise ImportError("filefinder2 : Unsupported python version")<commit_msg>making ns_hook publish in case hte client wants to do a search on sys.path_hook<commit_after>from __future__ import absolute_import, print_function

import sys

# Selective Import here to allow extending the import logic with other py2.7 importers
if (2, 7) <= sys.version_info < (3, 4):  # TODO : test : valid until which py3 version ?
    from ._filefinder2 import get_supported_ns_loaders, PathFinder2, NamespaceMetaFinder2, FileFinder2
    from ._fileloader2 import NamespaceLoader2, Loader2, SourceFileLoader2, ImpLoader

supported_loaders = get_supported_ns_loaders()
path_hook = FileFinder2.path_hook(*supported_loaders)

# Making the activation explicit for now
def activate():
    """Install the path-based import components."""
    if (2, 7) <= sys.version_info < (3, 4):  # TODO : test : valid until which py3 version ?
        ##### Note this must be early in the list, since we change the logic regarding what is a package or not
        #sys.path_hooks.insert(1, ns_hook)
        sys.path_hooks.append(path_hook)
        # Resetting sys.path_importer_cache values,
        # to support the case where we have an implicit package inside an already loaded package,
        # since we need to replace the default importer.
        sys.path_importer_cache.clear()

        # Setting up the meta_path to change package finding logic
        sys.meta_path.append(NamespaceMetaFinder2)

    else:
        # Useful to avoid traps since logic is likely different with finder and loader on python3
        raise ImportError("filefinder2 : Unsupported python version")
{'fraction_non_alphanumeric': 0.06718597857838364, 'fraction_numerical': 0.01622849724115547, 'mean_word_length': 3.683890577507599, 'pattern_counts': {'":': 0, '<': 11, '<?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': '3183585', 'n_tokens_mistral': 854, 'n_tokens_neox': 848, 'n_words': 327}