From 2718c89613be16c74d1cb94e033f8805719b5225 Mon Sep 17 00:00:00 2001 From: jonct <2807816+jonct@users.noreply.github.com> Date: Mon, 15 Jul 2024 00:44:44 -0400 Subject: [PATCH] Extract more config parser --- src/jlmkr/donor/jlmkr.py | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/jlmkr/donor/jlmkr.py b/src/jlmkr/donor/jlmkr.py index 6160553..8995555 100755 --- a/src/jlmkr/donor/jlmkr.py +++ b/src/jlmkr/donor/jlmkr.py @@ -139,7 +139,8 @@ else: DISCLAIMER = f"""{YELLOW}{BOLD}{__disclaimer__}{NORMAL}""" -from utils.config_parser import KeyValueParser, ExceptionWithParser +from utils.config_parser import ExceptionWithParser, KeyValueParser +from utils.config_parser import parse_config_file # Workaround for exit_on_error=False not applying to: @@ -381,20 +382,6 @@ def shell_jail(args): return subprocess.run(["machinectl", "shell"] + args).returncode -def parse_config_file(jail_config_path): - config = KeyValueParser() - # Read default config to fallback to default values - # for keys not found in the jail_config_path file - config.read_default_string(DEFAULT_CONFIG) - try: - with open(jail_config_path, "r") as fp: - config.read_file(fp) - return config - except FileNotFoundError: - eprint(f"Unable to find config file: {jail_config_path}.") - return - - def systemd_escape_path(path): """ Escape path containing spaces, while properly handling backslashes in filenames. @@ -1383,6 +1370,7 @@ def list_jails(): ) return 0 +from utils.parent_dataset import get_all_jail_names from utils.jail_dataset import parse_os_release