3 from config import config as cfg
7 from optparse import OptionParser
10 parser = OptionParser()
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""")
21 s1 = config.getListFromFile(f1)
22 s2 = config.getListFromFile(f2)
24 s = nodesets(config.operation, s1, s2)
26 if config.operation == "and":
27 print "Nodes in both sets", len(Set(s1) & Set(s2))
28 elif config.operation == "uniquetoone" or config.operation == "minus":
29 print "Nodes unique to set 1", len(Set(s1) - Set(s2))
30 elif operation == "or":
31 print "Union of nodes in both sets", len(Set(s1) | Set(s2))
37 def nodesets(operation, s1, s2):
39 if operation == "and":
40 return Set(s1) & Set(s2)
41 elif operation == "uniquetoone" or operation == "minus":
42 return Set(s1) - Set(s2)
43 elif operation == "or":
44 return Set(s1) | Set(s2)
46 print "Unknown operation: %s " % operation