blob: cc9705bde0e9cc17d75819507b4dd74abd58df3a (
plain)
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
|
#!/usr/bin/python
import collections, os, os.path, sys
import pkgcore.config # tested with pkgcore-0.6.4
def main(argv):
try:
outputdir = argv[1]
except IndexError:
print('Usage: %s output-directory/' % argv[0])
return 1
c = pkgcore.config.load_config()
portdir = c.repo['portdir']
output = collections.defaultdict(set)
for p in portdir:
for eclass in p.data['_eclasses_']:
output[eclass].add('%s/%s\n' % (p.category, p.PN))
try:
os.mkdir(outputdir)
except OSError:
pass # XXX: removing old eclasses?
os.chdir(outputdir)
for eclass in output:
f = open('%s.txt' % eclass, 'w')
f.writelines(sorted(output[eclass]))
f.close()
f = open('index.html', 'w')
f.write('''<!DOCTYPE html>
<html>
<head>
<style type="text/css">
li a { font-family: monospace; display: block; float: left; min-width: %dem; }
</style>
<title>Packages inheriting eclasses</title>
</head>
<body>
<h1>Packages inheriting eclasses</h1>
<ul>
%s
<li><a href="/">/ (go back)</a></li>
</ul>
</body>
</html>''' % (max([len(e) for e in output]), '\n'.join(['<li><a href="%s.txt">%s.eclass</a> (%d packages),</li>' % (e, e, len(output[e])) for e in sorted(output)])))
f.close()
return 0
if __name__ == '__main__':
sys.exit(main(sys.argv))
|