コード例 #1
0
 def test_expand_multi_range(self):
     expected = \
         'node1,node2,node3,node4,node5,node6,node7,node8,' \
         'node9,node10,node11,node12,node13,node14,node15,' \
         'node16,node18,node19,node21,node22'
     test = hl.expand('node[18-19,1-16,21-22]')
     self.assertEqual(test, expected)
コード例 #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))
コード例 #3
0
 def test_expand_only_commas(self):
     expected = 'node1,node2,node3'
     test = hl.expand('node[1,2,3]')
     self.assertEqual(test, expected)
コード例 #4
0
 def test_expand_leading_zeros(self):
     expected = 'machine2-009vm1,machine2-010vm1,machine2-011vm1'
     test = hl.expand('machine2-[009-11]vm1')
     self.assertEqual(test, expected)
コード例 #5
0
 def test_expand_scr(self):
     expected = \
         'machine2-02vm1,machine2-03vm1,' \
         'machine4-0003.vml2,machine4-0004.vml2,machine4-0005.vml2'
     test = hl.expand("machine2-[02-3]vm1, machine4-[0003-5].vml2")
     self.assertEqual(test, expected)
コード例 #6
0
 def test_expand_prefix_and_suffix(self):
     expected = 'machine2-02vm1,machine2-03vm1,machine2-04vm1'
     test = hl.expand('machine2-[02-4]vm1')
     self.assertEqual(test, expected)
コード例 #7
0
 def test_expand_mixed_range(self):
     expected = \
         'node4,node5,node6,node7,node8,node12,node16,node17,' \
         'node18,node19,node20,node22,node24,node25,node26'
     test = hl.expand('node[4-8,12,16-20,22,24-26]')
     self.assertEqual(test, expected)
コード例 #8
0
 def test_expand(self):
     expected = 'quartz4,quartz5,quartz6,quartz7,quartz8'
     test = hl.expand('quartz[4-8]')
     self.assertEqual(test, expected)