Exemplo n.º 1
0
 def test_intersect_multiple(self):
     expected = 'node[1,6,8]'
     list1 = ['node1', 'node2', 'node3', 'node4', 'node8', 'node6']
     list2 = ['node5', 'node6', 'node7', 'node8', 'node9', 'node1']
     list3 = ['node1', 'node6', 'node8', 'node7']
     test = hl.intersect(list1, list2, list3)
     self.assertEqual(test, expected)
Exemplo n.º 2
0
def main():
    parser = argparse.ArgumentParser(usage=msg())

    parser.add_argument("-d", "--delimiters", dest="delimiter", nargs="*")
    parser.add_argument("-s", "--size", dest="size_hostlist", nargs="*")
    parser.add_argument("-e", "--expand", dest="expand")
    parser.add_argument("-a", "--abbreviate", dest="compress_range")
    parser.add_argument("-t", "--tighten", dest="compress")
    parser.add_argument("-m", "--minus", dest="diff", nargs="*")
    parser.add_argument("-i", "--intersection", dest="intersection", nargs="*")
    parser.add_argument("-u", "--union", dest="union", nargs="*")
    parser.add_argument("-n", "--nth", dest="nth", nargs="*")
    parser.add_argument("-R", "--remove", dest="remove_node", nargs="*")
    parser.add_argument("-S", "--sort", dest="sort")
    parser.add_argument("-c", "--count", dest="count")
    parser.add_argument("-F", "--find", dest="find", nargs="*")
    parser.add_argument("-X", "--xor", dest="xor", nargs="*")
    parser.add_argument("-x", "--exclude", dest="exclude", nargs="*")
    parser.add_argument("-q", "--quiet", dest="quiet")
    parser.add_argument("-f", "--filter", dest="filter")

    args = parser.parse_args()

    if args.delimiter:
        print(hl.delimiter(args.delimiter[1], args.delimiter[0]))
    if args.size_hostlist:
        print(hl.size_hostlist(args.size_hostlist[1], int(args.size_hostlist[0])))
    if args.expand:
        print(hl.expand(args.expand))
    if args.compress_range:
        print(hl.compress_range(args.compress_range))
    if args.compress:
        print(hl.compress(args.compress))
    if args.diff:
        print(hl.diff(*args.diff))
    if args.intersection:
        print(hl.intersect(*args.intersection))
    if args.union:
        print(hl.union_nodes(*args.union))
    if args.nth:
        print(hl.nth(args.nth[1], args.nth[0]))
    if args.remove_node:
        print(hl.remove_node(args.remove_node[1], args.remove_node[0]))
    if args.sort:
        print(hl.sort_nodes(args.sort))
    if args.count:
        print(hl.count(args.count))
    if args.find:
        print(hl.find(args.find[1], args.find[0]))
    if args.xor:
        print(hl.xor(*args.xor))
    if args.exclude:
        print(hl.exclude(*args.exclude))
    if args.quiet:
        hl.quiet(args.quiet)
    if args.filter:
        print(hl.filter_python(args.filter))
Exemplo n.º 3
0
 def test_intersect_with_expand(self):
     expected = 'node[1,8]'
     list1 = 'node[1-4,8]'
     list2 = 'node[1,5-9]'
     test = hl.intersect(list1, list2)
     self.assertEqual(test, expected)
Exemplo n.º 4
0
 def test_instersect_as_string(self):
     expected = 'node[1,8]'
     list1 = 'node1,node2,node3,node4,node8'
     list2 = 'node5,node6,node7,node8,node9,node1'
     test = hl.intersect(list1, list2)
     self.assertEqual(test, expected)
Exemplo n.º 5
0
 def test_intersect_scr(self):
     expected = 'machine[1,3]'
     list1 = 'machine1,machine2,machine3'
     list2 = 'machine1,machine3,machine4'
     test = hl.intersect(list1, list2)
     self.assertEqual(test, expected)