6 import parser as parsermodule
10 parser = parsermodule.getParser()
11 parser.set_defaults(operation="and",)
12 parser.add_option("", "--operation", dest="operation", metavar="and",
13 help="""Which operation to perform on the two sets. (and, or, minus""")
15 config = parsermodule.parse_args(parser)
20 s1 = util.file.getListFromFile(f1)
21 s2 = util.file.getListFromFile(f2)
23 s = nodesets(config.operation, s1, s2)
25 if config.operation == "and":
26 print "Nodes in both sets", len(Set(s1) & Set(s2))
27 elif config.operation == "uniquetoone" or config.operation == "minus":
28 print "Nodes unique to set 1", len(Set(s1) - Set(s2))
29 elif operation == "or":
30 print "Union of nodes in both sets", len(Set(s1) | Set(s2))
36 def nodesets(operation, s1, s2):
38 if operation == "and":
39 return Set(s1) & Set(s2)
40 elif operation == "uniquetoone" or operation == "minus":
41 return Set(s1) - Set(s2)
42 elif operation == "or":
43 return Set(s1) | Set(s2)
45 print "Unknown operation: %s " % operation
49 if __name__ == "__main__":