Gentoo Archives: gentoo-commits

From: Krzysztof Pawlik <nelchael@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] dev/nelchael:master commit in: scripts/
Date: Sat, 11 Feb 2012 18:50:07
Message-Id: 1e16974c4a868f0871c82f7fe8b9359c13aac56e.nelchael@gentoo
1 commit: 1e16974c4a868f0871c82f7fe8b9359c13aac56e
2 Author: Krzysztof Pawlik <none <AT> none>
3 AuthorDate: Sat Feb 11 18:49:20 2012 +0000
4 Commit: Krzysztof Pawlik <nelchael <AT> gentoo <DOT> org>
5 CommitDate: Sat Feb 11 18:49:20 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=dev/nelchael.git;a=commit;h=1e16974c
7
8 Remove eshowkw.py, obsoleted by eshowkw from gentoolkit.
9
10 ---
11 scripts/eshowkw.py | 174 ----------------------------------------------------
12 1 files changed, 0 insertions(+), 174 deletions(-)
13
14 diff --git a/scripts/eshowkw.py b/scripts/eshowkw.py
15 deleted file mode 100755
16 index 00f5632..0000000
17 --- a/scripts/eshowkw.py
18 +++ /dev/null
19 @@ -1,174 +0,0 @@
20 -#!/usr/bin/python
21 -
22 -import sys
23 -import os
24 -
25 -search_path = os.getcwd()
26 -while search_path != '/':
27 - if os.path.exists(os.path.join(search_path, 'profiles/repo_name')):
28 - print 'Appending %s to PORTDIR_OVERLAY...' % search_path
29 - if 'PORTDIR_OVERLAY' not in os.environ:
30 - os.environ['PORTDIR_OVERLAY'] = search_path
31 - else:
32 - os.environ['PORTDIR_OVERLAY'] += ' ' + search_path
33 - search_path = os.path.dirname(search_path)
34 -
35 -import portage
36 -import portage.versions as portage_versions
37 -import portage.output as output
38 -
39 -def resolvePackage(db, item):
40 - cpvs = []
41 - try:
42 - cpvs = db.xmatch('match-all', item)
43 - except (Exception), e:
44 - print output.red('"%s" matches to more than one package:' % item)
45 - for x in e.args[0]:
46 - print ' ' + output.green('*') + ' ' + x
47 - sys.exit(0)
48 - if len(cpvs) == 0:
49 - print output.red('Package "%s" not found' % item)
50 - if item.find('/') != -1:
51 - item = item[item.find('/') + 1:]
52 - try:
53 - cpvs = db.xmatch('match-all', item)
54 - except (Exception), e:
55 - print 'Try:'
56 - for x in e.args[0]:
57 - print ' ' + output.green('*') + ' ' + x
58 - sys.exit(0)
59 - if len(cpvs) != 0:
60 - print 'Try:\n %s' % output.green('*') + ' ' + output.bold(portage_versions.pkgsplit(cpvs[0])[0])
61 - sys.exit(0)
62 - pkg = portage_versions.pkgsplit(cpvs[0])[0]
63 - vers = []
64 - for i in cpvs:
65 - vers.append(i[len(pkg) + 1:])
66 - # Sort versions:
67 - verRv = []
68 - for i in sorted(vers):
69 - skip = False
70 - for x in range(len(verRv)):
71 - if portage_versions.vercmp(i, verRv[x]) > 0:
72 - verRv.insert(x, i)
73 - skip = True
74 - break
75 - if not skip:
76 - verRv.append(i)
77 - vers = []
78 - for i in reversed(verRv):
79 - vers.append(i)
80 - return ( pkg, vers )
81 -
82 -def flagFor(arch, keywords, myArch):
83 - maskAll = False
84 - for x in keywords:
85 - tilde = False
86 - maskMe = False
87 - if x == '-*':
88 - maskAll = True
89 - continue
90 - if x[0] == '~':
91 - x = x[1:]
92 - tilde = True
93 - if x[0] == '-':
94 - x = x[1:]
95 - maskMe = True
96 - if x == arch:
97 - if tilde:
98 - if arch == myArch:
99 - return output.yellow('~')
100 - return output.darkyellow('~')
101 - if maskMe:
102 - if arch == myArch:
103 - return output.red('-')
104 - return output.darkred('-')
105 - if arch == myArch:
106 - return output.green('+')
107 - return output.darkgreen('+')
108 - if maskAll:
109 - if arch == myArch:
110 - return output.red('*')
111 - return output.darkred('*')
112 - return ' '
113 -
114 -def showMe(myArch, db, pkg):
115 - pkg, versions = resolvePackage(db, pkg)
116 - print '>>> Keywords for', pkg
117 - archs = []
118 - for i in open(portage.settings['PORTDIR'] + '/profiles/arch.list').readlines():
119 - if i == '':
120 - break
121 - i = i.strip()
122 - if i == '' or i[0] == '#':
123 - continue
124 - if not 'ESHOWKW_ALL_ARCHS' in os.environ and i.find('-') != -1:
125 - continue
126 - archs.append(i)
127 - longestVerLen = 0
128 - for i in versions:
129 - if len(i) > longestVerLen:
130 - longestVerLen = len(i)
131 - longestVerLen += 1
132 - longestSlot = 0
133 - for i in versions:
134 - slot = db.aux_get(pkg + '-' + i, [ 'SLOT' ])[0]
135 - if len(slot) > longestSlot:
136 - longestSlot = len(slot)
137 - lines = 0
138 - for i in archs:
139 - if len(i) > lines:
140 - lines = len(i)
141 - for i in range(lines):
142 - print longestVerLen * ' ' + '|',
143 - for x in archs:
144 - if x == myArch:
145 - if len(x) > i:
146 - print output.green(x[i]),
147 - else:
148 - print ' ',
149 - else:
150 - if len(x) > i:
151 - print x[i],
152 - else:
153 - print ' ',
154 - print '|',
155 - print
156 - print longestVerLen * '-' + '+-' + len(archs) * '--' + '+-' + (longestSlot + 3) * '-'
157 - sys.stdout.flush()
158 - prevSlot = None
159 - for x in versions:
160 - keywords, slot = db.aux_get(pkg + '-' + x, [ 'KEYWORDS', 'SLOT' ])
161 - keywords = keywords.split()
162 - slot = ' (' + slot + ')'
163 - if slot != prevSlot:
164 - print output.bold(x + (longestVerLen - len(x)) * ' ') + '|',
165 - else:
166 - print x + (longestVerLen - len(x)) * ' ' + '|',
167 - for a in archs:
168 - print flagFor(a, keywords, myArch),
169 - if slot != prevSlot:
170 - print '|' + output.blue(slot)
171 - else:
172 - print '|'
173 - #print '|' + output.darkblue(slot)
174 - prevSlot = slot
175 - sys.stdout.flush()
176 -
177 -pkg = None
178 -if len(sys.argv) == 1:
179 - if os.getcwd() != '/':
180 - pkg = os.path.basename(os.path.dirname(os.getcwd())) + '/' + os.path.basename(os.getcwd())
181 - else:
182 - print output.red('Can not get package name')
183 - sys.exit(1)
184 -else:
185 - pkg = sys.argv[1]
186 -
187 -myArch = None
188 -for i in portage.settings['ACCEPT_KEYWORDS'].split():
189 - myArch = i
190 - if i[0] == '~':
191 - myArch = i[1:]
192 -
193 -showMe(myArch, portage.portdbapi(mysettings=portage.settings), pkg)