Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Zac Medico <zmedico@g.o>
Subject: [gentoo-portage-dev] [PATCH v2] ekeyword: remove .ebuild file suffix requirement (bug 762331)
Date: Tue, 29 Dec 2020 03:06:57
Message-Id: 20201229030638.424385-1-zmedico@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH] ekeyword: remove .ebuild file suffix requirement (bug 762331) by Zac Medico
1 We'd like to use ekeyword in a git merge driver implementation, but the
2 files that the driver will pass to ekeyword do not necessarily have a
3 .ebuild suffix. Therefore, it would be handy to be able to distinguish
4 ebuild arguments some other way. If the ignorable_arg(arg) function
5 returns True and os.path.isfile(arg) returns True, then simply assume
6 that the argument is an ebuild.
7
8 Bug: https://bugs.gentoo.org/762331
9 Signed-off-by: Zac Medico <zmedico@g.o>
10 ---
11 [PATCH v2] fix to respect the ignorable_arg function
12
13 pym/gentoolkit/ekeyword/ekeyword.py | 9 ++++++---
14 1 file changed, 6 insertions(+), 3 deletions(-)
15
16 diff --git a/pym/gentoolkit/ekeyword/ekeyword.py b/pym/gentoolkit/ekeyword/ekeyword.py
17 index 4e57c09..eeceed4 100755
18 --- a/pym/gentoolkit/ekeyword/ekeyword.py
19 +++ b/pym/gentoolkit/ekeyword/ekeyword.py
20 @@ -244,7 +244,7 @@ def process_content(ebuild, data, ops, arch_status=None, verbose=0,
21 pass
22 else:
23 # Chop the full path and the .ebuild suffix.
24 - disp_name = os.path.basename(ebuild)[:-7]
25 + disp_name, _, _ = os.path.basename(ebuild).partition('.ebuild')
26 def logit(msg):
27 print('%s: %s' % (disp_name, msg))
28
29 @@ -395,7 +395,9 @@ def args_to_work(args, arch_status=None, _repo=None, quiet=0):
30 last_todo_arches = []
31
32 for arg in args:
33 - if arg.endswith('.ebuild'):
34 + if ignorable_arg(arg, quiet=quiet):
35 + pass
36 + elif os.path.isfile(arg):
37 if not todo_arches:
38 todo_arches = last_todo_arches
39 work.append([arg, todo_arches])
40 @@ -405,7 +407,7 @@ def args_to_work(args, arch_status=None, _repo=None, quiet=0):
41 op = arg_to_op(arg)
42 if not arch_status or op.arch in arch_status:
43 todo_arches.append(op)
44 - elif not ignorable_arg(arg, quiet=quiet):
45 + else:
46 raise ValueError('unknown arch/argument: %s' % arg)
47
48 if todo_arches:
49 @@ -475,6 +477,7 @@ def main(argv):
50 opts.style = 'color-inline'
51
52 arch_status = load_profile_data()
53 + print(arch_status)
54 try:
55 work = args_to_work(work_args, arch_status=arch_status, quiet=opts.quiet)
56 except ValueError as e:
57 --
58 2.26.2