1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
" Vim plugin
" Purpose: Common functionality for gentoo-syntax plugins
" Author: Ciaran McCreesh <ciaranm@gentoo.org>
" Copyright: Copyright (c) 2005 Ciaran McCreesh
" Licence: You may redistribute this under the same terms as Vim itself
if &compatible || v:version < 603 || exists("g:loaded_gentoo_common")
finish
endif
let g:loaded_gentoo_common=1
fun! GentooGetUser()
let l:result = expand("\$ECHANGELOG_USER")
if l:result ==# "\$ECHANGELOG_USER"
let l:gitcfg = "git config --global "
if executable(git)
let l:email = trim(system(l:gitcfg . "user.email"))
let l:name = trim(system(l:gitcfg . "user.name"))
else
let l:email = expand("$HOST")
let l:name = expand("$USER")
endif
let l:result = l:name . " <" . l:email . ">"
endif
return l:result
endfun
fun! GentooHeader(...)
" The shebang arg is optional
let l:year = strftime("%Y")
let l:copyright = '# Copyright ' . l:year . ' Gentoo Authors'
" Only one arg allowed (shebang only)
if a:0 == 1
0 put =a:1 " Insert shebang
put =l:copyright
else
0 put =l:copyright
endif
put ='# Distributed under the terms of the GNU General Public License v2'
$
endfun
fun! GentooGetArch()
if exists("g:gentooarch") && g:gentooarch != ""
return g:gentooarch
else
let l:a = system("portageq envvar ACCEPT_KEYWORDS 2>/dev/null")
let l:a = substitute(l:a, "[\\n~]", " ", "g")
let l:a = substitute(l:a, "^\\s\\+", "", "")
let l:a = substitute(l:a, "\\s.*", "", "")
if l:a == ""
let l:a = "amd64"
endif
let g:gentooarch = l:a
return g:gentooarch
endif
endfun
fun! GentooGetPythonTargets()
if exists("g:gentoopythontargets") && g:gentoopythontargets != ""
return g:gentoopythontargets
else
let l:pyexec_path = "/etc/python-exec/python-exec.conf"
if filereadable(l:pyexec_path)
let l:pys = readfile(l:pyexec_path)->filter("v:val =~ '^[^#-]'")
\ ->sort()
let l:py3s = []
let l:others = []
for l:py in l:pys
let l:m = l:py->matchstr("^python3.*")->matchstr("\\d*$")
if !empty(l:m)
eval l:py3s->add(l:m)
continue
else
eval l:others->add(l:py)
endif
endfor
let l:impls = []
if len(l:py3s) ==# 1
let l:impls = l:impls->add("python3_".l:py3s->join())
elseif len(l:py3s) > 1
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("[.]", "_", "g")
endif
let g:gentoopythontargets = l:py3
return g:gentoopythontargets
endif
endfun
" vim: set et foldmethod=marker sw=4 ts=4 : "
|