Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall
diff options
context:
space:
mode:
Diffstat (limited to 'archinstall')
-rw-r--r--archinstall/__init__.py30
-rw-r--r--archinstall/lib/plugins.py2
2 files changed, 27 insertions, 5 deletions
diff --git a/archinstall/__init__.py b/archinstall/__init__.py
index 3e9f8391..090ad7de 100644
--- a/archinstall/__init__.py
+++ b/archinstall/__init__.py
@@ -1,5 +1,6 @@
"""Arch Linux installer - guided, templates etc."""
-from argparse import ArgumentParser
+import typing
+from argparse import ArgumentParser, Namespace
from .lib.disk import *
from .lib.exceptions import *
@@ -132,6 +133,24 @@ def parse_unspecified_argument_list(unknowns :list, multiple :bool = False, erro
print(f" We ignore the entry {element} as it isn't related to any argument")
return config
+def cleanup_empty_args(args :typing.Union[Namespace, dict]) -> dict:
+ """
+ Takes arguments (dictionary or argparse Namespace) and removes any
+ None values. This ensures clean mergers during dict.update(args)
+ """
+ if type(args) == Namespace:
+ args = vars(args)
+
+ clean_args = {}
+ for key, val in args.items():
+ if type(val) == dict:
+ val = cleanup_empty_args(val)
+
+ if val is not None:
+ clean_args[key] = val
+
+ return clean_args
+
def get_arguments() -> Dict[str, Any]:
""" The handling of parameters from the command line
Is done on following steps:
@@ -159,14 +178,15 @@ def get_arguments() -> Dict[str, Any]:
exit(1)
# load the parameters. first the known, then the unknowns
- config.update(vars(args))
+ args = cleanup_empty_args(args)
+ config.update(args)
config.update(parse_unspecified_argument_list(unknowns))
# amend the parameters (check internal consistency)
# Installation can't be silent if config is not passed
- if args.config is not None :
- config["silent"] = args.silent
- else:
+ if args.get('config') is None:
config["silent"] = False
+ else:
+ config["silent"] = args.get('silent')
# avoiding a compatibility issue
if 'dry-run' in config:
diff --git a/archinstall/lib/plugins.py b/archinstall/lib/plugins.py
index f771aacb..0ff63610 100644
--- a/archinstall/lib/plugins.py
+++ b/archinstall/lib/plugins.py
@@ -73,6 +73,7 @@ def find_nth(haystack :List[str], needle :str, n :int) -> int:
def load_plugin(path :str) -> ModuleType:
parsed_url = urllib.parse.urlparse(path)
+ log(f"Loading plugin {parsed_url}.", fg="gray", level=logging.INFO)
# The Profile was not a direct match on a remote URL
if not parsed_url.scheme:
@@ -96,6 +97,7 @@ def load_plugin(path :str) -> ModuleType:
if hasattr(sys.modules[namespace], 'Plugin'):
try:
plugins[namespace] = sys.modules[namespace].Plugin()
+ log(f"Plugin {plugins[namespace]} has been loaded.", fg="gray", level=logging.INFO)
except Exception as err:
log(err, level=logging.ERROR)
log(f"The above error was detected when initiating the plugin: {path}", fg="red", level=logging.ERROR)