From: Daan De Meyer Date: Sat, 30 Sep 2023 15:54:58 +0000 (+0200) Subject: Stop hardcoding setting names we pass to parse_ini() X-Git-Tag: v18~22^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e31e89d72a67eaa211eaaa1c050b118d72bb0807;p=thirdparty%2Fmkosi.git Stop hardcoding setting names we pass to parse_ini() Instead, derive them from the settings list. --- 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