From a8e4f9297a38b3a0465b29aca32f14ce88720aa9 Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Wed, 26 Jan 2022 10:56:59 +0100 Subject: gentoo-common: Support collapsing PYTHON_COMPAT into {x..y} MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Górny --- plugin/gentoo-common.vim | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/plugin/gentoo-common.vim b/plugin/gentoo-common.vim index 306542e..bc4da76 100644 --- a/plugin/gentoo-common.vim +++ b/plugin/gentoo-common.vim @@ -80,22 +80,40 @@ fun! GentooGetPythonTargets() endfor let l:impls = [] if len(l:py3s) ==# 1 - let l:impls = l:impls->add("python3.".l:py3s->join()) + let l:impls = l:impls->add("python3_".l:py3s->join()) elseif len(l:py3s) > 1 - let l:impls = l:impls->add("python3.{".l:py3s->sort('N') - \ ->join(",")."}") + let l:min = "" + let l:max = "" + let l:py3s = l:py3s->sort('N') + for l:py in l:py3s + if l:min ==# "" + let l:min = l:py + let l:max = l:py + elseif l:py ==# l:max + 1 + let l:max = l:py + else + let l:max = "" + break + endif + endfor + + if l:max !=# "" + let l:impls = l:impls->add("python3_{".l:min.".." + \ .l:max."}") + else + let l:impls = l:impls->add("python3_{".l:py3s + \ ->join(",")."}") + endif endif let l:py3 = flatten(l:impls->add(l:others))->join() endif if empty(l:py3) let l:py3 = \ system("python -c 'import epython; print(epython.EPYTHON)'") - \ ->substitute("\n", "", "g") + \ ->substitute("\n", "", "g")->substitute("[.]", "_", "g") endif - let l:pythons = substitute(l:py3, "[.]", "_", "g") - - let g:gentoopythontargets = l:pythons + let g:gentoopythontargets = l:py3 return g:gentoopythontargets endif endfun -- cgit v1.2.3-65-gdbad