Gentoo Archives: gentoo-catalyst

From: Matt Turner <mattst88@g.o>
To: gentoo-catalyst@l.g.o
Cc: Matt Turner <mattst88@g.o>
Subject: [gentoo-catalyst] [PATCH] catalyst: Switch to tomli
Date: Sun, 30 Jan 2022 23:19:45
Message-Id: 20220130231932.405151-1-mattst88@gentoo.org
1 The Python community is coalescing around tomli, and tomli is likely to
2 be integrated into the standard library per PEP680.
3
4 Signed-off-by: Matt Turner <mattst88@g.o>
5 ---
6 catalyst/base/stagebase.py | 6 +++---
7 catalyst/main.py | 5 +++--
8 doc/make_subarch_table_guidexml.py | 5 +++--
9 3 files changed, 9 insertions(+), 7 deletions(-)
10
11 diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
12 index 4a1b4eb6..de1e30ef 100644
13 --- a/catalyst/base/stagebase.py
14 +++ b/catalyst/base/stagebase.py
15 @@ -10,7 +10,7 @@ from pathlib import Path
16
17 import fasteners
18 import libmount
19 -import toml
20 +import tomli
21
22 from snakeoil import fileutils
23 from snakeoil.osutils import pjoin
24 @@ -123,8 +123,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
25 log.debug("\tTrying %s", x)
26 name = x[:-len('.toml')]
27
28 - with open(arch_dir + x) as file:
29 - arch_config = toml.load(file)
30 + with open(arch_dir + x, 'rb') as file:
31 + arch_config = tomli.load(file)
32
33 # Search for a subarchitecture in each arch in the arch_config
34 for arch in [x for x in arch_config if x.startswith(name) and host in arch_config[x]]:
35 diff --git a/catalyst/main.py b/catalyst/main.py
36 index 0de1040f..6e9a2d3e 100644
37 --- a/catalyst/main.py
38 +++ b/catalyst/main.py
39 @@ -6,7 +6,7 @@ import os
40 import sys
41 import textwrap
42
43 -import toml
44 +import tomli
45
46 from DeComp.definitions import (COMPRESS_DEFINITIONS, DECOMPRESS_DEFINITIONS,
47 CONTENTS_DEFINITIONS)
48 @@ -35,7 +35,8 @@ def parse_config(config_files):
49 for config_file in config_files:
50 log.notice('Loading configuration file: %s', config_file)
51 try:
52 - config = toml.load(config_file)
53 + with open(config_file, 'rb') as f:
54 + config = tomli.load(f)
55 for key in config:
56 if key not in valid_config_file_values:
57 log.critical("Unknown option '%s' in config file %s",
58 diff --git a/doc/make_subarch_table_guidexml.py b/doc/make_subarch_table_guidexml.py
59 index 67ed3ccc..3c03f90c 100755
60 --- a/doc/make_subarch_table_guidexml.py
61 +++ b/doc/make_subarch_table_guidexml.py
62 @@ -5,7 +5,7 @@
63 import pathlib
64 import sys
65 import textwrap
66 -import toml
67 +import tomli
68
69
70 def write_guidexml(arch_to_subarch):
71 @@ -40,7 +40,8 @@ def main(_argv):
72 p = pathlib.Path('arch')
73
74 for file in p.glob('*.toml'):
75 - data = toml.load(file)
76 + with file.open('rb') as f:
77 + data = tomli.load(f)
78
79 for arch in [x for x in data if x != 'setarch']:
80 arch_to_subarch.update({arch: list(data[arch].keys())})
81 --
82 2.34.1