plugin.py 文件源码

python
阅读 34 收藏 0 点赞 0 评论 0

项目:supremm 作者: ubccr 项目源码 文件源码
def loadplugins(plugindir=None, namespace="plugins"):
    """ Load all of the modules from the plugins directory and instantiate the
        classes within. """

    if plugindir == None:
        plugindir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "plugins")

    analytics = []

    for _, x, _ in pkgutil.iter_modules([plugindir]):
        m1 = __import__('supremm.' + namespace + '.' + x)
        m = getattr(m1, namespace)
        m = getattr(m, x)
        c = getattr(m, x)
        if issubclass(c, Plugin) or issubclass(c, PreProcessor):
            analytics.append(c)
        else:
            del m1

    return analytics
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号