diff options
author | Eric Anderson <ejona86@gmail.com> | 2014-07-04 12:07:32 -0700 |
---|---|---|
committer | Eric Anderson <ejona86@gmail.com> | 2014-07-04 12:07:32 -0700 |
commit | 48842e37d3c7da2e8c8d0027676eea9493d13bb4 (patch) | |
tree | cd67f0011fa622d1c1fc336739dac85902874d9b | |
parent | 733dc676c6a6f6612014f5d912db43cf26d3063d (diff) | |
download | capset-48842e37d3c7da2e8c8d0027676eea9493d13bb4.tar.gz capset-48842e37d3c7da2e8c8d0027676eea9493d13bb4.zip |
Add post-process script to remove sub-capsets
-rwxr-xr-x | subcapset.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/subcapset.py b/subcapset.py new file mode 100755 index 0000000..fe8868f --- /dev/null +++ b/subcapset.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 +"""Detects and removes sub-capsets. + +[00 01 10] is a subcapset of [00 01 10 22], and thus would be filtered.""" + +from sys import argv + +def main(): + if len(argv) == 2: + infile = argv[1] + else: + print("Usage: %s INFILE" % argv[0]) + exit(1) + capsets = [] + capset_file = open(infile, "r") + for line in capset_file: + capsets.append(tuple(line[1:-2].split(" "))) + capset_file.close() + + capsetSet = set(capsets) + for capset in capsets: + for i in range(len(capset)): + capsetSet.discard(capset[:i] + capset[i+1:]) + for capset in capsets: + if capset in capsetSet: + print("[" + " ".join(capset) + "]") + +if __name__ == "__main__": + main() |