Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/plugins.py
blob: f7f8bc4ef36011a9ae7d52685db693c4ff308151 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import pkgutil
import importlib
import imp # Deprecated
from .storage import storage

plugins = {}
PLUGIN_PREFIXES = 'archinstall-'

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))