You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.3 KiB
40 lines
1.3 KiB
#!/usr/bin/env python
|
|
'''
|
|
Copyright (C) 2020, WAFW00F Developers.
|
|
See the LICENSE file for copying permission.
|
|
'''
|
|
|
|
import os
|
|
from functools import partial
|
|
from pluginbase import PluginBase
|
|
|
|
def load_plugins():
|
|
"""
|
|
加载插件的函数。
|
|
|
|
这个函数用于加载位于特定目录下的插件,并将它们存储在一个字典中以便后续使用。
|
|
"""
|
|
here = os.path.abspath(os.path.dirname(__file__))
|
|
# 创建一个函数,用于根据给定的路径片段生成完整路径
|
|
get_path = partial(os.path.join, here)
|
|
# 获取插件目录的路径
|
|
plugin_dir = get_path('plugins')
|
|
|
|
# 创建一个插件基础对象,指定插件所在的包和搜索路径
|
|
plugin_base = PluginBase(
|
|
package='client.webinfo.wafw00f.plugins', searchpath=[plugin_dir]
|
|
)
|
|
# 创建一个插件源对象,用于加载插件
|
|
plugin_source = plugin_base.make_plugin_source(
|
|
searchpath=[plugin_dir], persist=True
|
|
)
|
|
|
|
# 创建一个空字典,用于存储插件
|
|
plugin_dict = {}
|
|
# 遍历插件源中的所有插件名称
|
|
for plugin_name in plugin_source.list_plugins():
|
|
# 将插件名称作为键,加载的插件对象作为值,添加到字典中
|
|
plugin_dict[plugin_name] = plugin_source.load_plugin(plugin_name)
|
|
|
|
# 返回包含所有加载的插件的字典
|
|
return plugin_dict |