summaryrefslogtreecommitdiff
path: root/subcapset.py
diff options
context:
space:
mode:
authorJoe Anderson <jandew+dev@gmail.com>2014-07-05 14:50:17 -0500
committerJoe Anderson <jandew+dev@gmail.com>2014-07-05 14:50:17 -0500
commitfb55c50124608f630b18f762a2d912234bf4a35f (patch)
tree77173d1d0dcdbc89272df40207a676b296d83fa4 /subcapset.py
parent856a421ed9dbbbca63f985b35be2a9738f40b121 (diff)
downloadcapset-master.tar.gz
capset-master.zip
Standardized usage for subcapset.pyHEADmaster
Diffstat (limited to 'subcapset.py')
-rwxr-xr-xsubcapset.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/subcapset.py b/subcapset.py
index fe8868f..375dc1b 100755
--- a/subcapset.py
+++ b/subcapset.py
@@ -3,27 +3,30 @@
[00 01 10] is a subcapset of [00 01 10 22], and thus would be filtered."""
-from sys import argv
+from sys import argv, stdout
def main():
- if len(argv) == 2:
- infile = argv[1]
- else:
- print("Usage: %s INFILE" % argv[0])
- exit(1)
+ if len(argv) <= 1: infile = "capset.out"
+ if len(argv) > 1: infile = argv[1]
+ if len(argv) <= 2: outfile = "capset.filtered"
+ if len(argv) > 2: outfile = argv[2]
+
capsets = []
capset_file = open(infile, "r")
for line in capset_file:
capsets.append(tuple(line[1:-2].split(" ")))
capset_file.close()
+ if outfile:
+ stdout = open(outfile, "w")
+
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) + "]")
+ print("[" + " ".join(capset) + "]", file=stdout)
if __name__ == "__main__":
main()