diff options
author | Michał Górny <mgorny@gentoo.org> | 2022-01-26 10:56:59 +0100 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2022-02-03 09:36:47 +0100 |
commit | a8e4f9297a38b3a0465b29aca32f14ce88720aa9 (patch) | |
tree | 266ff43d8dc4c3a54d4039e0284619c9fbbea3aa | |
parent | newmetadata: Include pypi remote-id (diff) | |
download | gentoo-syntax-a8e4f9297a38b3a0465b29aca32f14ce88720aa9.tar.gz gentoo-syntax-a8e4f9297a38b3a0465b29aca32f14ce88720aa9.tar.bz2 gentoo-syntax-a8e4f9297a38b3a0465b29aca32f14ce88720aa9.zip |
gentoo-common: Support collapsing PYTHON_COMPAT into {x..y}
Signed-off-by: Michał Górny <mgorny@gentoo.org>
-rw-r--r-- | plugin/gentoo-common.vim | 32 |
1 files 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 |