From 7780de0509555e58c4757ed985bac3a7633a87ef Mon Sep 17 00:00:00 2001 From: Jens Diemer Date: Mon, 3 Apr 2023 09:41:32 +0200 Subject: [PATCH 1/2] Use the new standard tomllib library It was introduced in python3.11, available on bookworm --- tests/test_app.py | 4 ++-- tests/test_catalog.py | 6 +++--- tests/test_configurations.py | 4 ++-- tests/test_manifest.py | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/test_app.py b/tests/test_app.py index eecb0af..ca31b3f 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -6,7 +6,7 @@ import subprocess import sys -import toml +import tomllib from lib.lib_package_linter import ( Error, Info, @@ -564,7 +564,7 @@ def config_panel(app): yield from validate_schema( "config_panel", json.loads(config_panel_v1_schema()), - toml.load(app.path + "/config_panel.toml"), + tomllib.load(app.path + "/config_panel.toml"), ) @test() diff --git a/tests/test_catalog.py b/tests/test_catalog.py index fe52f0c..b1c5f65 100644 --- a/tests/test_catalog.py +++ b/tests/test_catalog.py @@ -7,7 +7,7 @@ import time from datetime import datetime -import toml +import tomllib from lib.lib_package_linter import ( Critical, Error, @@ -42,7 +42,7 @@ def __init__(self, app_id): self._fetch_app_repo() try: - self.app_list = toml.loads(open("./.apps/apps.toml").read()) + self.app_list = tomllib.loads(open("./.apps/apps.toml").read()) except Exception: _print("Failed to read apps.toml :/") sys.exit(-1) @@ -205,7 +205,7 @@ def get_history(N): elif os.system(f"git -C ./.apps cat-file -e {commit}:apps.toml") == 0: raw_catalog_at_this_date = git(["show", f"{commit}:apps.toml"]) - loader = toml + loader = tomllib else: raise Exception("No apps.json/toml at this point in history?") diff --git a/tests/test_configurations.py b/tests/test_configurations.py index 2b94b12..1acac3e 100644 --- a/tests/test_configurations.py +++ b/tests/test_configurations.py @@ -5,7 +5,7 @@ import re import subprocess -import toml +import tomllib from lib.lib_package_linter import ( Error, Info, @@ -49,7 +49,7 @@ def tests_toml(self): yield from validate_schema( "tests.toml", json.loads(tests_v1_schema()), - toml.load(app.path + "/tests.toml"), + tomllib.load(app.path + "/tests.toml"), ) @test() diff --git a/tests/test_manifest.py b/tests/test_manifest.py index f068e87..c570726 100644 --- a/tests/test_manifest.py +++ b/tests/test_manifest.py @@ -6,7 +6,7 @@ import re import sys -import toml +import tomllib from lib.lib_package_linter import ( Critical, Error, @@ -89,7 +89,7 @@ def check_for_duplicate_keys(ordered_pairs): self.raw_manifest = open(manifest_path, encoding="utf-8").read() try: - self.manifest = toml.loads(self.raw_manifest) + self.manifest = tomllib.loads(self.raw_manifest) except Exception as e: print( c.FAIL From 34cb83ffd6dc8336af60948e79e54c02649b65e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Sat, 16 Nov 2024 15:15:47 +0100 Subject: [PATCH 2/2] tomllib requires binary open() --- tests/test_app.py | 2 +- tests/test_catalog.py | 2 +- tests/test_configurations.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_app.py b/tests/test_app.py index ca31b3f..721e025 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -564,7 +564,7 @@ def config_panel(app): yield from validate_schema( "config_panel", json.loads(config_panel_v1_schema()), - tomllib.load(app.path + "/config_panel.toml"), + tomllib.load(open(app.path + "/config_panel.toml", "rb")), ) @test() diff --git a/tests/test_catalog.py b/tests/test_catalog.py index b1c5f65..452359b 100644 --- a/tests/test_catalog.py +++ b/tests/test_catalog.py @@ -42,7 +42,7 @@ def __init__(self, app_id): self._fetch_app_repo() try: - self.app_list = tomllib.loads(open("./.apps/apps.toml").read()) + self.app_list = tomllib.load(open("./.apps/apps.toml", "rb")) except Exception: _print("Failed to read apps.toml :/") sys.exit(-1) diff --git a/tests/test_configurations.py b/tests/test_configurations.py index 1acac3e..fa5e510 100644 --- a/tests/test_configurations.py +++ b/tests/test_configurations.py @@ -49,7 +49,7 @@ def tests_toml(self): yield from validate_schema( "tests.toml", json.loads(tests_v1_schema()), - tomllib.load(app.path + "/tests.toml"), + tomllib.load(open(app.path + "/tests.toml", "rb")), ) @test()