Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall
diff options
context:
space:
mode:
authorAnton Hvornum <anton@hvornum.se>2021-04-30 16:45:42 +0200
committerAnton Hvornum <anton@hvornum.se>2021-04-30 16:45:42 +0200
commit404197dc93c2efb24097772848af708d833bdd98 (patch)
tree0d9c54aff4e9e4dfe2966b621e1183c629587092 /archinstall
parent25b699b44ea272e9bac7d75c7d86871e082122ae (diff)
Enabling --plugins filtering
Diffstat (limited to 'archinstall')
-rw-r--r--archinstall/__init__.py4
-rw-r--r--archinstall/lib/plugins.py25
2 files changed, 21 insertions, 8 deletions
diff --git a/archinstall/__init__.py b/archinstall/__init__.py
index 82bba81e..a1fa4216 100644
--- a/archinstall/__init__.py
+++ b/archinstall/__init__.py
@@ -14,7 +14,6 @@ from .lib.packages import *
from .lib.output import *
from .lib.storage import *
from .lib.hardware import *
-from .lin.plugins import plugins
__version__ = "2.2.0"
@@ -33,6 +32,9 @@ for arg in sys.argv[1:]:
else:
positionals.append(arg)
+storage['arguments'] = arguments
+from .lib.plugins import plugins
+
# TODO: Learn the dark arts of argparse...
# (I summon thee dark spawn of cPython)
diff --git a/archinstall/lib/plugins.py b/archinstall/lib/plugins.py
index f744661a..f7f8bc4e 100644
--- a/archinstall/lib/plugins.py
+++ b/archinstall/lib/plugins.py
@@ -1,13 +1,24 @@
import pkgutil
import importlib
import imp # Deprecated
+from .storage import storage
plugins = {}
+PLUGIN_PREFIXES = 'archinstall-'
-for module_info in pkgutil.iter_modules(path=None, prefix=''):
- if 'archinstall-' in module_info.name and module_info.ispkg:
- try:
- modulesource = importlib.import_module(module_info.name)
- imp.reload(modulesource)
- except Exception as e:
- print('Could not load plugin {} {}'.format(modname, e)) \ No newline at end of file
+if (plugin_list := storage.get('plugins', None)):
+ if type(plugin_list) == str and plugin_list != '*':
+ plugin_list = plugin_list.split(',')
+
+ for module_info in pkgutil.iter_modules(path=None, prefix=''):
+ if not module_info.ispkg:
+ 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)) \ No newline at end of file