summaryrefslogtreecommitdiff
path: root/subcapset.py
diff options
context:
space:
mode:
Diffstat (limited to 'subcapset.py')
-rwxr-xr-xsubcapset.py29
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()