Skip to content

Commit 6834781

Browse files
authored
Merge pull request #94 from aliceinwire/toml
pyproject: Update toml dependency to tomllib
2 parents 1722aed + c7cb3bf commit 6834781

File tree

6 files changed

+14
-37
lines changed

6 files changed

+14
-37
lines changed

kcidev/libs/common.py

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22
# -*- coding: utf-8 -*-
33

44
import os
5+
import sys
56

67
import click
7-
import toml
8+
9+
if sys.version_info >= (3, 11):
10+
import tomllib
11+
else:
12+
import tomli as tomllib
813

914

1015
def load_toml(settings, subcommand):
@@ -13,8 +18,8 @@ def load_toml(settings, subcommand):
1318

1419
if os.path.exists(settings):
1520
if os.path.isfile(settings):
16-
with open(settings, "r") as f:
17-
config = toml.load(f)
21+
with open(settings, "rb") as f:
22+
config = tomllib.load(f)
1823
else:
1924
kci_err("The --settings location is not a kci-dev config file")
2025
raise click.Abort()
@@ -23,43 +28,19 @@ def load_toml(settings, subcommand):
2328
home_dir = os.path.expanduser("~")
2429
user_path = os.path.join(home_dir, ".config", "kci-dev", fname)
2530
if os.path.exists(user_path):
26-
with open(user_path, "r") as f:
27-
config = toml.load(f)
31+
with open(user_path, "rb") as f:
32+
config = tomllib.load(f)
2833
return config
2934

3035
global_path = os.path.join("/", "etc", fname)
3136
if os.path.exists(global_path):
32-
with open(global_path, "r") as f:
33-
config = toml.load(f)
34-
return config
35-
36-
example_configuration = ".kci-dev.toml.example"
37-
# Installed with Poetry
38-
poetry_example_configuration = os.path.join(
39-
os.path.dirname(__file__), "../..", example_configuration
40-
)
41-
if os.path.exists(poetry_example_configuration):
42-
if subcommand != "config":
43-
kci_err(f"Please use `kci-dev config` to create a config file")
44-
with open(poetry_example_configuration, "r") as f:
45-
config = toml.load(f)
46-
return config
47-
48-
# Installed with PyPI
49-
kci_err(f"Configuration not found")
50-
pypi_example_configuration = os.path.join(
51-
os.path.dirname(__file__), "..", example_configuration
52-
)
53-
if os.path.exists(pypi_example_configuration):
54-
if subcommand != "config":
55-
kci_err(f"Please use `kci-dev config` to create a config file")
56-
with open(pypi_example_configuration, "r") as f:
57-
config = toml.load(f)
37+
with open(global_path, "rb") as f:
38+
config = tomllib.load(f)
5839
return config
5940

6041
if not config:
6142
kci_err(
62-
f"No `{fname}` configuration file found at `{global_path}`, `{user_path}` or `{settings}`"
43+
f"No config file found, please use `kci-dev config` to create a config file"
6344
)
6445
raise click.Abort()
6546

kcidev/subcommands/bisect.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import click
1111
import requests
12-
import toml
1312
from git import Repo
1413

1514
from kcidev.libs.common import *

kcidev/subcommands/commit.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import click
77
import requests
8-
import toml
98
from git import Repo
109

1110

kcidev/subcommands/maestro_results.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import click
88
import requests
9-
import toml
109
from git import Repo
1110

1211
from kcidev.libs.common import *

kcidev/subcommands/patch.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import click
77
import requests
8-
import toml
98
from git import Repo
109

1110
from kcidev.libs.maestro_common import *

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ classifiers = [
3232
python = "^3.10"
3333
click = "^8.1.7"
3434
requests = "^2.32.3"
35-
toml = "^0.10.2"
3635
gitpython = "^3.1.43"
36+
tomli = { version = "^2.2.1", python = "<3.11" }
3737

3838
[tool.poetry.scripts]
3939
kci-dev = 'kcidev.main:run'

0 commit comments

Comments
 (0)