1 |
commit: 195b8029ddd510188e8a2510dad5cbce67c44ecc |
2 |
Author: Kenneth Raplee <kenrap <AT> kennethraplee <DOT> com> |
3 |
AuthorDate: Fri Mar 25 12:41:54 2022 +0000 |
4 |
Commit: Sam James <sam <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Mar 27 23:06:46 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=195b8029 |
7 |
|
8 |
Consolidate checks for options with bad atoms |
9 |
|
10 |
Signed-off-by: Kenneth Raplee <kenrap <AT> kennethraplee.com> |
11 |
Signed-off-by: Sam James <sam <AT> gentoo.org> |
12 |
|
13 |
lib/_emerge/main.py | 57 +++++++++++++---------------------------------------- |
14 |
1 file changed, 14 insertions(+), 43 deletions(-) |
15 |
|
16 |
diff --git a/lib/_emerge/main.py b/lib/_emerge/main.py |
17 |
index f3ff02404..01dc1b419 100644 |
18 |
--- a/lib/_emerge/main.py |
19 |
+++ b/lib/_emerge/main.py |
20 |
@@ -876,52 +876,23 @@ def parse_opts(tmpcmdline, silent=False): |
21 |
if myoptions.depclean_lib_check in true_y: |
22 |
myoptions.depclean_lib_check = True |
23 |
|
24 |
- if myoptions.exclude: |
25 |
- bad_atoms = _find_bad_atoms(myoptions.exclude) |
26 |
- if bad_atoms and not silent: |
27 |
- parser.error( |
28 |
- "Invalid Atom(s) in --exclude parameter: '%s' (only package names and slot atoms (with wildcards) allowed)\n" |
29 |
- % (",".join(bad_atoms),) |
30 |
- ) |
31 |
- |
32 |
- if myoptions.reinstall_atoms: |
33 |
- bad_atoms = _find_bad_atoms(myoptions.reinstall_atoms) |
34 |
- if bad_atoms and not silent: |
35 |
- parser.error( |
36 |
- "Invalid Atom(s) in --reinstall-atoms parameter: '%s' (only package names and slot atoms (with wildcards) allowed)\n" |
37 |
- % (",".join(bad_atoms),) |
38 |
- ) |
39 |
- |
40 |
- if myoptions.rebuild_exclude: |
41 |
- bad_atoms = _find_bad_atoms(myoptions.rebuild_exclude) |
42 |
- if bad_atoms and not silent: |
43 |
- parser.error( |
44 |
- "Invalid Atom(s) in --rebuild-exclude parameter: '%s' (only package names and slot atoms (with wildcards) allowed)\n" |
45 |
- % (",".join(bad_atoms),) |
46 |
- ) |
47 |
- |
48 |
- if myoptions.rebuild_ignore: |
49 |
- bad_atoms = _find_bad_atoms(myoptions.rebuild_ignore) |
50 |
- if bad_atoms and not silent: |
51 |
- parser.error( |
52 |
- "Invalid Atom(s) in --rebuild-ignore parameter: '%s' (only package names and slot atoms (with wildcards) allowed)\n" |
53 |
- % (",".join(bad_atoms),) |
54 |
- ) |
55 |
- |
56 |
- if myoptions.usepkg_exclude: |
57 |
- bad_atoms = _find_bad_atoms(myoptions.usepkg_exclude) |
58 |
- if bad_atoms and not silent: |
59 |
- parser.error( |
60 |
- "Invalid Atom(s) in --usepkg-exclude parameter: '%s' (only package names and slot atoms (with wildcards) allowed)\n" |
61 |
- % (",".join(bad_atoms),) |
62 |
- ) |
63 |
+ candidate_bad_options = ( |
64 |
+ (myoptions.exclude, "exclude"), |
65 |
+ (myoptions.reinstall_atoms, "reinstall-atoms"), |
66 |
+ (myoptions.rebuild_exclude, "rebuild-exclude"), |
67 |
+ (myoptions.rebuild_ignore, "rebuild-ignore"), |
68 |
+ (myoptions.usepkg_exclude, "usepkg-exclude"), |
69 |
+ (myoptions.useoldpkg_atoms, "useoldpkg-atoms"), |
70 |
+ ) |
71 |
+ bad_options = ( |
72 |
+ (_find_bad_atoms(atoms), flag) for atoms, flag in candidate_bad_options if atoms |
73 |
+ ) |
74 |
|
75 |
- if myoptions.useoldpkg_atoms: |
76 |
- bad_atoms = _find_bad_atoms(myoptions.useoldpkg_atoms) |
77 |
+ for bad_atoms, flag in bad_options: |
78 |
if bad_atoms and not silent: |
79 |
+ invalid_atoms = ",".join(bad_atoms) |
80 |
parser.error( |
81 |
- "Invalid Atom(s) in --useoldpkg-atoms parameter: '%s' (only package names and slot atoms (with wildcards) allowed)\n" |
82 |
- % (",".join(bad_atoms),) |
83 |
+ f"Invalid Atom(s) in --{flag} parameter: '{invalid_atoms}' (only package names and slot atoms (with wildcards) allowed)\n" |
84 |
) |
85 |
|
86 |
if myoptions.fail_clean in true_y: |