diff options
author | Michał Górny <mgorny@gentoo.org> | 2011-06-21 19:31:42 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2011-06-21 19:33:48 +0200 |
commit | d685925b2aec1969e159becadc946298dd47850d (patch) | |
tree | 5b00b9db3b77ed4a86fafb3a234d46c5b637d838 /packages-inheriting-eclasses.py | |
parent | Add find-binary-files.pl output to index.html (diff) | |
download | qa-scripts-d685925b2aec1969e159becadc946298dd47850d.tar.gz qa-scripts-d685925b2aec1969e159becadc946298dd47850d.tar.bz2 qa-scripts-d685925b2aec1969e159becadc946298dd47850d.zip |
Add a script to list packages which use a particular eclass.
Diffstat (limited to 'packages-inheriting-eclasses.py')
-rwxr-xr-x | packages-inheriting-eclasses.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/packages-inheriting-eclasses.py b/packages-inheriting-eclasses.py new file mode 100755 index 0000000..900426b --- /dev/null +++ b/packages-inheriting-eclasses.py @@ -0,0 +1,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)) |