Skip to content

Commit

Permalink
Merge pull request #103 from adfinis/revert-98-jlf/config_file.py
Browse files Browse the repository at this point in the history
Revert "doc: ai update config_file.py"
  • Loading branch information
Jean-Louis Fuchs authored Apr 5, 2024
2 parents e4d0d7b + a5c32e8 commit 4928d0c
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions pyaptly/config_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@


def yaml_to_toml(yaml_path: Path, toml_path: Path, *, add_defaults: bool = False):
"""
Convert pyaptly config files from YAML to TOML format.
"""Convert pyaptly config files from yaml to toml.
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.
Setting `add_defaults=True` will set common default during conversion.
"""
with yaml_path.open("r", encoding="UTF-8") as yf:
with toml_path.open("wb") as tf:
Expand All @@ -23,14 +19,8 @@ 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: 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'.
"""
def add_default_to_config(config):
"""Set common default in config if the fields are missing."""
if "mirror" in config:
for mirror in config["mirror"].values():
if "components" not in mirror:
Expand Down

0 comments on commit 4928d0c

Please sign in to comment.