def choose_multiple_from_map(somemap, chosen=None, prompt="choose multiple",
            input=raw_input, error=default_error):
    """Choose multiple items from a mapping.
    Returns a mapping of items chosen. Type in the key to select the values.
    """
    somemap = somemap.copy()
    if chosen is None:
        chosen = {}
    while 1:
        print("Choose from list. Enter to end, negative index removes from chosen.")
        if somemap:
            first = print_menu_map(somemap)
        else:
            print("(You have selected all possible choices.)")
            first = 0
        if chosen:
            print("You have: ")
            print_menu_map(chosen)
        try:
            ri = get_input(prompt, None, input) # menu list starts at one
        except EOFError:
            return chosen
        if not ri:
            return chosen
        try:
            idx = type(first)(ri)
        except ValueError:
            error("Bad selection. Please try again.")
            continue
        else:
            if idx < 0: # FIXME assumes numeric keys
                idx = -idx # FIXME handle zero index
                try:
                    somemap[idx] = chosen[idx]
                    del chosen[idx]
                except __HOLE__:
                    error("Selection out of range.")
            else:
                try:
                    chosen[idx] = somemap[idx]
                    del somemap[idx]
                except KeyError:
                    error("Selection out of range.")
dataset/ETHPy150Open kdart/pycopia/core/pycopia/cliutils.py/choose_multiple_from_map