6 import parser as parsermodule
9 parser = parsermodule.getParser()
10 parser.set_defaults(operation="and",)
11 parser.add_option("", "--operation", dest="operation", metavar="and",
12 help="""Which operation to perform on the two sets. (and, or, minus""")
14 config = parsermodule.parse_args(parser)
19 s1 = config.getListFromFile(f1)
20 s2 = config.getListFromFile(f2)
22 s = nodesets(config.operation, s1, s2)
24 if config.operation == "and":
25 print "Nodes in both sets", len(Set(s1) & Set(s2))
26 elif config.operation == "uniquetoone" or config.operation == "minus":
27 print "Nodes unique to set 1", len(Set(s1) - Set(s2))
28 elif operation == "or":
29 print "Union of nodes in both sets", len(Set(s1) | Set(s2))
35 def nodesets(operation, s1, s2):
37 if operation == "and":
38 return Set(s1) & Set(s2)
39 elif operation == "uniquetoone" or operation == "minus":
40 return Set(s1) - Set(s2)
41 elif operation == "or":
42 return Set(s1) | Set(s2)
44 print "Unknown operation: %s " % operation