diff options
author | 2011-10-18 16:00:13 +0200 | |
---|---|---|
committer | 2011-10-18 16:00:13 +0200 | |
commit | c8fd3c42664821fabdc7af7c976f197a4c5551c6 (patch) | |
tree | 408e9c943db0f14c0ad0749baee8126542d3a718 | |
parent | Improve batch stabilization: (diff) | |
download | arch-tools-c8fd3c42664821fabdc7af7c976f197a4c5551c6.tar.gz arch-tools-c8fd3c42664821fabdc7af7c976f197a4c5551c6.tar.bz2 arch-tools-c8fd3c42664821fabdc7af7c976f197a4c5551c6.zip |
Implement limit option for reverse dependencies.
-rwxr-xr-x | reverse-dependencies.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/reverse-dependencies.py b/reverse-dependencies.py index 88d79aa..4f87139 100755 --- a/reverse-dependencies.py +++ b/reverse-dependencies.py @@ -4,6 +4,7 @@ import optparse import os +import random import types os.environ["PORTDIR_OVERLAY"] = "" @@ -31,6 +32,7 @@ if __name__ == "__main__": parser = optparse.OptionParser() parser.add_option("-i", "--input", dest="input_filename", default="package.keywords", help="Input filename for generated package.keywords file [default=%default]") parser.add_option("-o", "--output", dest="output_filename", default="package.rdeps", help="Output filename for generated package.rdeps file [default=%default]") + parser.add_option("-l", "--limit", dest="limit", type="int", default=-1, help="Limit of reverse dependencies per package. Default is no limit.") parser.add_option("-v", "--verbose", dest="verbose", action="store_true", default=False) (options, args) = parser.parse_args() @@ -68,7 +70,12 @@ if __name__ == "__main__": pn = portage.versions.pkgsplit(cpv)[0] if pn in reverse_deps: output_file.write("# Reverse dependencies for %s\n" % pn) - for cp, use_combinations in reverse_deps[pn].items(): + if options.limit == -1: + cps = reverse_deps[pn] + else: + cps = random.sample(reverse_deps[pn], min(options.limit, len(reverse_deps[pn]))) + for cp in cps: + use_combinations = reverse_deps[pn][cp] if use_combinations != [[]]: output_file.write("# One of the following USE flag combinations is required:\n") for use_combination in use_combinations: |