Skip to content

Commit

Permalink
Merge pull request #68 from adfinis/jlf/chore-switch-to-toml
Browse files Browse the repository at this point in the history
chore: switch to toml (no merge)
  • Loading branch information
Jean-Louis Fuchs authored Mar 4, 2024
2 parents 620ba84 + 23d67f8 commit f5e1fb0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 19 deletions.
13 changes: 1 addition & 12 deletions pyaptly/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

import freezegun
import pytest
import tomli
import yaml

from pyaptly import main, state_reader, util

Expand Down Expand Up @@ -114,16 +112,7 @@ def test_mirror_create(environment, config, caplog):
...
```
"""
config_file = test_base / request.param
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:
yaml.dump(config, f)
yield f.name
finally:
Path(f.name).unlink()
yield str(test_base / request.param)


@pytest.fixture()
Expand Down
7 changes: 3 additions & 4 deletions pyaptly/main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
"""Aptly mirror/snapshot managment automation."""
import argparse
import codecs
import logging
import sys

import yaml
import tomli

from . import command, mirror, publish, repo, snapshot, state_reader

Expand Down Expand Up @@ -84,8 +83,8 @@ def main(argv=None):
_logging_setup = True # noqa
lg.debug("Args: %s", vars(args))

with codecs.open(args.config, "r", encoding="UTF-8") as cfgfile:
cfg = yaml.load(cfgfile, Loader=yaml.FullLoader)
with open(args.config, "rb") as f:
cfg = tomli.load(f)
state_reader.state.read()

# run function for selected subparser
Expand Down
6 changes: 3 additions & 3 deletions pyaptly/tests/test_dateround.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os.path

import pytest
import yaml
import tomli
from hypothesis import given
from hypothesis.strategies import datetimes, integers, times

Expand Down Expand Up @@ -173,8 +173,8 @@ def test_daily_examples():
@pytest.mark.parametrize("config", ["publish-previous.toml"], indirect=True)
def test_snapshot_spec_to_name(config, test_path, freeze):
"""Test the complete functionality (snapshot_spec_to_name)."""
with (test_path / config).open("r") as f:
tyml = yaml.load(f, Loader=yaml.FullLoader)
with open(config, "rb") as f:
tyml = tomli.load(f)
snaps = tyml["snapshot"]["superfake-%T"]["merge"]

rounded1 = snapshot.snapshot_spec_to_name(tyml, snaps[0])
Expand Down

0 comments on commit f5e1fb0

Please sign in to comment.