def parseArgs(cllist, arg_proto, arg_proto_map={}, argmap = {}):

    def etoi(a):
        '''Maps argument's external (cli name) to internal name'''
        return arg_proto_map[a].internal_name

    ##starting out, init argmap and arg_proto_map
    if not bool(argmap):
        argmap = dict(map(attrgetter("internal_name","default"), arg_proto))
        arg_proto_map = dict(zip(map(attrgetter("name"),arg_proto),arg_proto))

    if not cllist:
        cllist = []
        
    if len(cllist) == 0  or not cllist[0].startswith("-"):
        return ParsedArgs(argmap,cllist)

    #remove the "-"
    cur = cllist[0][1:]
    
    if not cur in arg_proto_map:
        raise Exception, "Unknown argument '%s'\n" % cur

    if arg_proto_map[cur].type == argflag:
        argmap[etoi(cur)] = True
        return parseArgs(cllist[1:], arg_proto, arg_proto_map, argmap)

    if "=" in cur:
        k,v = cur.split("=")
        argmap[etoi(k)] = arg_proto_map[k].type(v)
        return parseArgs(cllist[1:],arg_proto,arg_proto_map, argmap)

    if not len(cllist) > 1:
        raise Exception, "Dangling arg '%s'\n" % cur

    argmap[etoi(cur)] = arg_proto_map[cur].type(cllist[1])
    return parseArgs(cllist[2:], arg_proto, arg_proto_map, argmap)
Remove a capability.
dataset/ETHPy150Open jgurtowski/ectools/args.py/parseArgs--crossover with--dataset/ETHPy150Open ncclient/ncclient/ncclient/capabilities.py/Capabilities.remove