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 0E81915808B for ; Sun, 27 Mar 2022 23:07:18 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A7D99E097A; Sun, 27 Mar 2022 23:07:15 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 75D8EE0992 for ; Sun, 27 Mar 2022 23:07:14 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 8D73A3436AD for ; Sun, 27 Mar 2022 23:07:13 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id AD70A34E for ; Sun, 27 Mar 2022 23:07:10 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1648422406.195b8029ddd510188e8a2510dad5cbce67c44ecc.sam@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: lib/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: lib/_emerge/main.py X-VCS-Directories: lib/_emerge/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 195b8029ddd510188e8a2510dad5cbce67c44ecc X-VCS-Branch: master Date: Sun, 27 Mar 2022 23:07:10 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: ad524b9a-86af-49db-97bb-01ea080262f0 X-Archives-Hash: a0d6e764c90273e807d4a8edf4f3ad60 commit: 195b8029ddd510188e8a2510dad5cbce67c44ecc Author: Kenneth Raplee kennethraplee com> AuthorDate: Fri Mar 25 12:41:54 2022 +0000 Commit: Sam James gentoo org> CommitDate: Sun Mar 27 23:06:46 2022 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=195b8029 Consolidate checks for options with bad atoms Signed-off-by: Kenneth Raplee kennethraplee.com> Signed-off-by: Sam James gentoo.org> lib/_emerge/main.py | 57 +++++++++++++---------------------------------------- 1 file changed, 14 insertions(+), 43 deletions(-) diff --git a/lib/_emerge/main.py b/lib/_emerge/main.py index f3ff02404..01dc1b419 100644 --- a/lib/_emerge/main.py +++ b/lib/_emerge/main.py @@ -876,52 +876,23 @@ def parse_opts(tmpcmdline, silent=False): if myoptions.depclean_lib_check in true_y: myoptions.depclean_lib_check = True - if myoptions.exclude: - bad_atoms = _find_bad_atoms(myoptions.exclude) - if bad_atoms and not silent: - parser.error( - "Invalid Atom(s) in --exclude parameter: '%s' (only package names and slot atoms (with wildcards) allowed)\n" - % (",".join(bad_atoms),) - ) - - if myoptions.reinstall_atoms: - bad_atoms = _find_bad_atoms(myoptions.reinstall_atoms) - if bad_atoms and not silent: - parser.error( - "Invalid Atom(s) in --reinstall-atoms parameter: '%s' (only package names and slot atoms (with wildcards) allowed)\n" - % (",".join(bad_atoms),) - ) - - if myoptions.rebuild_exclude: - bad_atoms = _find_bad_atoms(myoptions.rebuild_exclude) - if bad_atoms and not silent: - parser.error( - "Invalid Atom(s) in --rebuild-exclude parameter: '%s' (only package names and slot atoms (with wildcards) allowed)\n" - % (",".join(bad_atoms),) - ) - - if myoptions.rebuild_ignore: - bad_atoms = _find_bad_atoms(myoptions.rebuild_ignore) - if bad_atoms and not silent: - parser.error( - "Invalid Atom(s) in --rebuild-ignore parameter: '%s' (only package names and slot atoms (with wildcards) allowed)\n" - % (",".join(bad_atoms),) - ) - - if myoptions.usepkg_exclude: - bad_atoms = _find_bad_atoms(myoptions.usepkg_exclude) - if bad_atoms and not silent: - parser.error( - "Invalid Atom(s) in --usepkg-exclude parameter: '%s' (only package names and slot atoms (with wildcards) allowed)\n" - % (",".join(bad_atoms),) - ) + candidate_bad_options = ( + (myoptions.exclude, "exclude"), + (myoptions.reinstall_atoms, "reinstall-atoms"), + (myoptions.rebuild_exclude, "rebuild-exclude"), + (myoptions.rebuild_ignore, "rebuild-ignore"), + (myoptions.usepkg_exclude, "usepkg-exclude"), + (myoptions.useoldpkg_atoms, "useoldpkg-atoms"), + ) + bad_options = ( + (_find_bad_atoms(atoms), flag) for atoms, flag in candidate_bad_options if atoms + ) - if myoptions.useoldpkg_atoms: - bad_atoms = _find_bad_atoms(myoptions.useoldpkg_atoms) + for bad_atoms, flag in bad_options: if bad_atoms and not silent: + invalid_atoms = ",".join(bad_atoms) parser.error( - "Invalid Atom(s) in --useoldpkg-atoms parameter: '%s' (only package names and slot atoms (with wildcards) allowed)\n" - % (",".join(bad_atoms),) + f"Invalid Atom(s) in --{flag} parameter: '{invalid_atoms}' (only package names and slot atoms (with wildcards) allowed)\n" ) if myoptions.fail_clean in true_y: