From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id C4900158087 for ; Sun, 30 Jan 2022 23:19:45 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id F0A632BC001; Sun, 30 Jan 2022 23:19:44 +0000 (UTC) Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 887A52BC001 for ; Sun, 30 Jan 2022 23:19:44 +0000 (UTC) Received: by mail-pl1-f170.google.com with SMTP id k17so11077561plk.0 for ; Sun, 30 Jan 2022 15:19:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2WCiMhEojakQjBqK8liVB8Cy5vFP7qpWGswBobmuZSo=; b=mEG2eFdifP8rwkcTAc//PBSkgYkWJ6AUyfcD5A5qQEHGxznyMbTNP68N5O5SV/80fG msurD5LxHpOyMQ4rPP/0pz9a3FGZypkJf+S5FaH9r6OTkwLGs8UppcLo2sri2JcCoc1U dSgQ3OZSlMMLGkEL8KsV4GhcwJR6RNQe5sau8jcFh9t3CnOItkKDYoDMnjqmKYrrNENn jRZT4TWxxYRZo8tHWBP5e054Kk9097kb9w41R8JFXZWb5fvpaHIUAiXqTuMXR8PmBnNW WyjSpPWeaUs6EIxC+x88ZIcORwegPm+3gHdY6gdGnZlgS/J6lATjaOc0KftCMNZTTn8b aC0g== X-Gm-Message-State: AOAM530M9Jl6F/oEgVnWssFa9x4QHTsY2dnzwzbYmFyc+EfEZ99RedLs AeK1RZCXT6+2DrM9u+9H3NoEcrqA8aQ= X-Google-Smtp-Source: ABdhPJw++3ekCFPXfdylIrmzsodx4YAZfh0RuJSchqiSxjfsXGbF3ZH8cqkxCjhQ00L1AZHwbrd5WA== X-Received: by 2002:a17:902:b215:: with SMTP id t21mr18808387plr.73.1643584783017; Sun, 30 Jan 2022 15:19:43 -0800 (PST) Received: from localhost ([108.161.26.224]) by smtp.gmail.com with ESMTPSA id j8sm14663633pfc.48.2022.01.30.15.19.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jan 2022 15:19:42 -0800 (PST) From: Matt Turner To: gentoo-catalyst@lists.gentoo.org Cc: Matt Turner Subject: [gentoo-catalyst] [PATCH] catalyst: Switch to tomli Date: Sun, 30 Jan 2022 15:19:32 -0800 Message-Id: <20220130231932.405151-1-mattst88@gentoo.org> X-Mailer: git-send-email 2.34.1 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-catalyst@lists.gentoo.org Reply-to: gentoo-catalyst@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Archives-Salt: 3779bfab-edcd-4dfe-9177-b7760fde47a4 X-Archives-Hash: c9f8c00702b0268e2cf01892cb5fe394 The Python community is coalescing around tomli, and tomli is likely to be integrated into the standard library per PEP680. Signed-off-by: Matt Turner --- catalyst/base/stagebase.py | 6 +++--- catalyst/main.py | 5 +++-- doc/make_subarch_table_guidexml.py | 5 +++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 4a1b4eb6..de1e30ef 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -10,7 +10,7 @@ from pathlib import Path import fasteners import libmount -import toml +import tomli from snakeoil import fileutils from snakeoil.osutils import pjoin @@ -123,8 +123,8 @@ class StageBase(TargetBase, ClearBase, GenBase): log.debug("\tTrying %s", x) name = x[:-len('.toml')] - with open(arch_dir + x) as file: - arch_config = toml.load(file) + with open(arch_dir + x, 'rb') as file: + arch_config = tomli.load(file) # Search for a subarchitecture in each arch in the arch_config for arch in [x for x in arch_config if x.startswith(name) and host in arch_config[x]]: diff --git a/catalyst/main.py b/catalyst/main.py index 0de1040f..6e9a2d3e 100644 --- a/catalyst/main.py +++ b/catalyst/main.py @@ -6,7 +6,7 @@ import os import sys import textwrap -import toml +import tomli from DeComp.definitions import (COMPRESS_DEFINITIONS, DECOMPRESS_DEFINITIONS, CONTENTS_DEFINITIONS) @@ -35,7 +35,8 @@ def parse_config(config_files): for config_file in config_files: log.notice('Loading configuration file: %s', config_file) try: - config = toml.load(config_file) + with open(config_file, 'rb') as f: + config = tomli.load(f) for key in config: if key not in valid_config_file_values: log.critical("Unknown option '%s' in config file %s", diff --git a/doc/make_subarch_table_guidexml.py b/doc/make_subarch_table_guidexml.py index 67ed3ccc..3c03f90c 100755 --- a/doc/make_subarch_table_guidexml.py +++ b/doc/make_subarch_table_guidexml.py @@ -5,7 +5,7 @@ import pathlib import sys import textwrap -import toml +import tomli def write_guidexml(arch_to_subarch): @@ -40,7 +40,8 @@ def main(_argv): p = pathlib.Path('arch') for file in p.glob('*.toml'): - data = toml.load(file) + with file.open('rb') as f: + data = tomli.load(f) for arch in [x for x in data if x != 'setarch']: arch_to_subarch.update({arch: list(data[arch].keys())}) -- 2.34.1