<commit_before>import logging
import sys
from itertools import chain
from pathlib import Path


logger = logging.getLogger(__name__)


def load_plugin(module: str):
    if module in sys.modules:
        return
    try:
        m = __import__(module, fromlist=['plugin'])
    except ModuleNotFoundError:
        return
    if not hasattr(m, 'plugin'):
        return
    plugin = m.plugin
    if callable(plugin):
        plugin = plugin()
    if isinstance(plugin, Plugin):
        return plugin
    return ProxyPlugin(plugin)


def get_names():
    for path in sys.path:
        path = Path(path)
        if not path.is_dir():
            continue
        for i in path.glob('aioworkers*'):
            yield i.with_suffix('').name


def search_plugins(*modules):
    result = []
    for name in chain(get_names(), modules):
        plugin = load_plugin(name)
        if plugin:
            logger.info('Loaded plugin {} from {}'.format(plugin, name))
            result.append(plugin)
    return result
<commit_msg>fix py35 ImportError<commit_after>import logging
import sys
from itertools import chain
from pathlib import Path


logger = logging.getLogger(__name__)


def load_plugin(module: str):
    if module in sys.modules:
        return
    try:
        m = __import__(module, fromlist=['plugin'])
    except ImportError:
        return
    if not hasattr(m, 'plugin'):
        return
    plugin = m.plugin
    if callable(plugin):
        plugin = plugin()
    if isinstance(plugin, Plugin):
        return plugin
    return ProxyPlugin(plugin)


def get_names():
    for path in sys.path:
        path = Path(path)
        if not path.is_dir():
            continue
        for i in path.glob('aioworkers*'):
            yield i.with_suffix('').name


def search_plugins(*modules):
    result = []
    for name in chain(get_names(), modules):
        plugin = load_plugin(name)
        if plugin:
            logger.info('Loaded plugin {} from {}'.format(plugin, name))
            result.append(plugin)
    return result

{'fraction_non_alphanumeric': 0.10034431874077718, 'fraction_numerical': 0.000983767830791933, 'mean_word_length': 2.407035175879397, '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': '6241518', 'n_tokens_mistral': 581, 'n_tokens_neox': 569, 'n_words': 172}