From 619511f31386c6574bf3c0cef3934ba58750b41b Mon Sep 17 00:00:00 2001 From: Jean-Louis Fuchs Date: Fri, 22 Mar 2024 16:05:14 +0100 Subject: [PATCH] doc: ai update config_file.py --- pyaptly/config_file.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/pyaptly/config_file.py b/pyaptly/config_file.py index aeef53d..ad67bb5 100644 --- a/pyaptly/config_file.py +++ b/pyaptly/config_file.py @@ -7,9 +7,13 @@ def yaml_to_toml(yaml_path: Path, toml_path: Path, *, add_defaults: bool = False): - """Convert pyaptly config files from yaml to toml. + """ + Convert pyaptly config files from YAML to TOML format. - Setting `add_defaults=True` will set common default during conversion. + The conversion process reads a configuration from the file located at `yaml_path`, + converts it to TOML format, and writes the result to the file specified by + `toml_path`. If `add_defaults` is set to True, common defaults are applied during + the conversion. """ with yaml_path.open("r", encoding="UTF-8") as yf: with toml_path.open("wb") as tf: @@ -19,8 +23,14 @@ def yaml_to_toml(yaml_path: Path, toml_path: Path, *, add_defaults: bool = False tomli_w.dump(config, tf) -def add_default_to_config(config): - """Set common default in config if the fields are missing.""" +def add_default_to_config(config: dict): + """ + Set common defaults in `config` if the fields are missing. + + This function checks for missing 'components' and 'distribution' fields under both + 'mirror' and 'publish' sections of the configuration. If these fields are missing, + it sets them to 'main'. + """ if "mirror" in config: for mirror in config["mirror"].values(): if "components" not in mirror: