def _load_plugins_from_dir(path):
    """
    Load plugins from a given path
    """
    plugins = []
    loaded_plugins = []

    # Expand out any ~'s
    full_path = os.path.expanduser(path)

    # Check if the dir exists, by asking for forgiveness
    try:
        filtered = fnmatch.filter(os.listdir(path), '*.py')
        plugins.extend(filtered)
    except __HOLE__:
        # Uhoh, the path we were given doesn't exist/can't be read...
        pass
    else:
        # We read in the plugin dir, so lets add it to the load path
        sys.path.insert(1, path)

    # Import the thing(s)
    for plugin in plugins:
        match = re.search('(?P<name>.*)(?P<ext>\.py$)', plugin)
        if match:
            try:
                __import__(match.group('name'), globals(), locals(), [], -1)
            except:
                pass
            else:
                loaded_plugins.append(match.group('name'))
    return loaded_plugins
dataset/ETHPy150Open RHInception/jsonstats/JsonStats/Utils.py/_load_plugins_from_dir