Skip to content

Commit

Permalink
Merge pull request #54 from ganwell/chore-switch-to-tomli
Browse files Browse the repository at this point in the history
chore: switch to tomli
  • Loading branch information
Jean-Louis Fuchs authored Feb 23, 2024
2 parents f92c2f4 + efc73a7 commit 7ae885e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

25 changes: 18 additions & 7 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pyaptly/config_file.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Handling pyaptly config-files."""
from pathlib import Path

import toml
import tomli_w
import yaml


Expand All @@ -11,11 +11,11 @@ def yaml_to_toml(yaml_path: Path, toml_path: Path, *, add_defaults: bool = False
Setting `add_defaults=True` will set common default during conversion.
"""
with yaml_path.open("r", encoding="UTF-8") as yf:
with toml_path.open("w", encoding="UTF-8") as tf:
with toml_path.open("wb") as tf:
config = yaml.safe_load(yf)
if add_defaults:
add_default_to_config(config)
toml.dump(config, tf)
tomli_w.dump(config, tf)


def add_default_to_config(config):
Expand Down
6 changes: 3 additions & 3 deletions pyaptly/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import freezegun
import pytest
import toml
import tomli
import yaml

import pyaptly
Expand Down Expand Up @@ -116,8 +116,8 @@ def test_mirror_create(environment, config, caplog):
```
"""
config_file = test_base / request.param
with config_file.open("r", encoding="UTF-8") as f:
config = toml.load(f)
with config_file.open("rb") as f:
config = tomli.load(f)
# TODO: remove yaml conversion
try:
with tempfile.NamedTemporaryFile(mode="w", encoding="UTF-8", delete=False) as f:
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ python = "^3.11"
pretty-dump = {git = "https://github.com/adfinis/freeze"}
pytz = "^2023.3.post1"
pyyaml = "^6.0.1"
toml = "^0.10.2"
click = "^8.1.7"
tomli = "^2.0.1"
tomli-w = "^1.0.0"

[tool.poetry.group.dev.dependencies]
freezegun = "^1.2.2"
Expand Down

0 comments on commit 7ae885e

Please sign in to comment.