Esempio n. 1
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))
Esempio n. 2
0
 def test_count_multi_ranges(self):
     expected = 10
     test = hl.count('node[1-5,6-10]')
     self.assertEqual(test, expected)
Esempio n. 3
0
 def test_count_with_expand(self):
     expected = 5
     test = hl.count('node[1-5]')
     self.assertEqual(test, expected)
Esempio n. 4
0
 def test_count_as_list(self):
     expected = 5
     test = hl.count(['node1', 'node2', 'node3', 'node4', 'node5'])
     self.assertEqual(test, expected)
Esempio n. 5
0
 def test_count(self):
     expected = 5
     test = hl.count('node1,node2,node3,node4,node5')
     self.assertEqual(test, expected)