Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use tomlkit for TOML read/write operations #215

Merged
merged 5 commits into from
Mar 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions config/config-package.py
Original file line number Diff line number Diff line change
@@ -18,13 +18,12 @@
from shared.git import get_commit_id
from shared.git import git_branch
from shared.path import change_dir
from shared.toml_encoder import TomlArraySeparatorEncoderWithNewline
import argparse
import collections
import jinja2
import pathlib
import shutil
import toml
import tomlkit


META_HINT = """\
@@ -67,13 +66,13 @@ def handle_command_line_arguments():
'--no-flake8',
dest='use_flake8',
action='store_false',
default=None,
default=True,
help='Do not include flake8 and isort in the linting configuration.')
parser.add_argument(
'--with-appveyor',
dest='with_appveyor',
action='store_true',
default=None,
default=False,
help='Activate running tests on AppVeyor, too, '
'if not already configured in .meta.toml.')
parser.add_argument(
@@ -111,7 +110,7 @@ def handle_command_line_arguments():
'--with-sphinx',
dest='with_docs',
action='store_true',
default=None,
default=False,
help='Activate building docs if not already configured in .meta.toml.')
parser.add_argument(
'--with-sphinx-doctests',
@@ -178,7 +177,8 @@ def _read_meta_configuration(self):
"""Read and update meta configuration"""
meta_toml_path = self.path / '.meta.toml'
if meta_toml_path.exists():
meta_cfg = toml.load(meta_toml_path)
with open(meta_toml_path, 'rb') as meta_f:
meta_cfg = tomlkit.load(meta_f)
meta_cfg = collections.defaultdict(dict, **meta_cfg)
else:
meta_cfg = collections.defaultdict(dict)
@@ -636,10 +636,7 @@ def configure(self):
with open('.meta.toml', 'w') as meta_f:
meta_f.write(META_HINT.format(config_type=self.config_type))
meta_f.write('\n')
toml.dump(
meta_cfg, meta_f,
TomlArraySeparatorEncoderWithNewline(
separator=',\n ', indent_first_line=True))
tomlkit.dump(meta_cfg, meta_f)

tox_path = shutil.which('tox') or (
pathlib.Path(cwd) / 'bin' / 'tox')
5 changes: 3 additions & 2 deletions config/drop-legacy-python.py
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@
import pathlib
import shutil
import sys
import toml
import tomlkit


parser = argparse.ArgumentParser(
@@ -56,7 +56,8 @@
with change_dir(path) as cwd_str:
cwd = pathlib.Path(cwd_str)
bin_dir = cwd / 'bin'
meta_cfg = collections.defaultdict(dict, **toml.load('.meta.toml'))
with open('.meta.toml', 'rb') as meta_f:
meta_cfg = collections.defaultdict(dict, **tomlkit.load(meta_f))
config_type = meta_cfg['meta']['template']
branch_name = get_branch_name(args.branch_name, config_type)
updating = git_branch(branch_name)
114 changes: 0 additions & 114 deletions config/meta-cfg-to-toml.py

This file was deleted.

10 changes: 5 additions & 5 deletions config/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
check-python-versions==0.20.0
check-python-versions==0.21.3
Jinja2==3.1.3
pyupgrade==3.3.1
toml==0.10.2
tox==4.0.14
zest.releaser==7.2.0
pyupgrade==3.3.2
tomlkit==0.12.1
tox==4.8.0
zest.releaser==8.0.0
47 changes: 0 additions & 47 deletions config/shared/toml_encoder.py

This file was deleted.