Gentoo Archives: gentoo-commits

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