From e31e89d72a67eaa211eaaa1c050b118d72bb0807 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sat, 30 Sep 2023 17:54:58 +0200 Subject: [PATCH] Stop hardcoding setting names we pass to parse_ini() Instead, derive them from the settings list. --- mkosi/config.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/mkosi/config.py b/mkosi/config.py index b5dda1b50..eeac69d28 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -18,9 +18,9 @@ import shutil import subprocess import textwrap import uuid -from collections.abc import Iterable, Iterator, Sequence +from collections.abc import Collection, Iterable, Iterator, Sequence from pathlib import Path -from typing import Any, Callable, Optional, Union, cast +from typing import Any, Callable, Collection, Optional, Union, cast from mkosi.architecture import Architecture from mkosi.distributions import Distribution, detect_distribution @@ -870,7 +870,7 @@ class MkosiConfig: } -def parse_ini(path: Path, only_sections: Sequence[str] = ()) -> Iterator[tuple[str, str, str]]: +def parse_ini(path: Path, only_sections: Collection[str] = ()) -> Iterator[tuple[str, str, str]]: """ We have our own parser instead of using configparser as the latter does not support specifying the same setting multiple times in the same configuration file. @@ -2039,9 +2039,7 @@ def parse_config(argv: Sequence[str] = ()) -> tuple[MkosiArgs, tuple[MkosiConfig if path.exists(): logging.debug(f"Including configuration file {Path.cwd() / path}") - for section, k, v in parse_ini( - path, only_sections=["Distribution", "Output", "Content", "Validation", "Host", "Preset"] - ): + for section, k, v in parse_ini(path, only_sections={s.section for s in SETTINGS}): name = k.removeprefix("@") ns = namespace if k == name else defaults -- 2.47.3