Enabling --plugins filtering
This commit is contained in:
parent
25b699b44e
commit
404197dc93
|
|
@ -14,7 +14,6 @@ from .lib.packages import *
|
||||||
from .lib.output import *
|
from .lib.output import *
|
||||||
from .lib.storage import *
|
from .lib.storage import *
|
||||||
from .lib.hardware import *
|
from .lib.hardware import *
|
||||||
from .lin.plugins import plugins
|
|
||||||
|
|
||||||
__version__ = "2.2.0"
|
__version__ = "2.2.0"
|
||||||
|
|
||||||
|
|
@ -33,6 +32,9 @@ for arg in sys.argv[1:]:
|
||||||
else:
|
else:
|
||||||
positionals.append(arg)
|
positionals.append(arg)
|
||||||
|
|
||||||
|
storage['arguments'] = arguments
|
||||||
|
from .lib.plugins import plugins
|
||||||
|
|
||||||
# TODO: Learn the dark arts of argparse...
|
# TODO: Learn the dark arts of argparse...
|
||||||
# (I summon thee dark spawn of cPython)
|
# (I summon thee dark spawn of cPython)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,24 @@
|
||||||
import pkgutil
|
import pkgutil
|
||||||
import importlib
|
import importlib
|
||||||
import imp # Deprecated
|
import imp # Deprecated
|
||||||
|
from .storage import storage
|
||||||
|
|
||||||
plugins = {}
|
plugins = {}
|
||||||
|
PLUGIN_PREFIXES = 'archinstall-'
|
||||||
|
|
||||||
for module_info in pkgutil.iter_modules(path=None, prefix=''):
|
if (plugin_list := storage.get('plugins', None)):
|
||||||
if 'archinstall-' in module_info.name and module_info.ispkg:
|
if type(plugin_list) == str and plugin_list != '*':
|
||||||
try:
|
plugin_list = plugin_list.split(',')
|
||||||
modulesource = importlib.import_module(module_info.name)
|
|
||||||
imp.reload(modulesource)
|
for module_info in pkgutil.iter_modules(path=None, prefix=''):
|
||||||
except Exception as e:
|
if not module_info.ispkg:
|
||||||
print('Could not load plugin {} {}'.format(modname, e))
|
continue
|
||||||
|
|
||||||
|
# If --plugins=* and <iterator:plugin> == 'archinstall-'
|
||||||
|
# of --plugins=name is <iterator:plugin>
|
||||||
|
if (plugin_list == '*' and PLUGIN_PREFIXES in module_info.name) or (module_info.name in plugin_list):
|
||||||
|
try:
|
||||||
|
modulesource = importlib.import_module(module_info.name)
|
||||||
|
imp.reload(modulesource)
|
||||||
|
except Exception as e:
|
||||||
|
print('Could not load plugin {} {}'.format(modname, e))
|
||||||
Loading…
Reference in New Issue