def many(prompt, *args, **kwargs):
    """Calls `pick` in a while loop to allow user to pick many
    options. Returns a list of chosen options.
    """
    def get_options(options, chosen):
        return [options[i] for i, c in enumerate(chosen) if c]

    def get_verbose_options(verbose_options, chosen):
        no, yes = ' ', '✔'
        if sys.version_info < (3, 3):
            no, yes = ' ', '@'
        opts = ['{} {}'.format(yes if c else no, verbose_options[i]) for i, c in enumerate(chosen)]
        return opts + ['{}{}'.format('  ', kwargs.get('done', 'done...'))]

    options, verbose_options = prepare_options(args)
    chosen = [False] * len(options)
    index = kwargs.get('idx', 0)

    default = kwargs.get('default', None)
    if isinstance(default, list):
        for idx in default:
            chosen[idx] = True
    if isinstance(default, int):
        chosen[default] = True

    while True:
        try:
            index = one(prompt, *get_verbose_options(verbose_options, chosen), return_index=True, idx=index)
        except QuestionnaireGoBack:
            if any(chosen):
                raise QuestionnaireGoBack(0)
            else:
                raise QuestionnaireGoBack
        if index == len(options):
            return get_options(options, chosen)
        chosen[index] = not chosen[index]
def many(prompt, *args, **kwargs):
    """Calls `pick` in a while loop to allow user to pick many
    options. Returns a list of chosen options.
    """
    def get_options(options, chosen):
        return [options[i] for i, c in enumerate(chosen) if c]

    def get_verbose_options(verbose_options, chosen):
        no, yes = ' ', '✔'
        if sys.version_info < (3, 3):
            no, yes = ' ', '@'
        opts = ['{} {}'.format(yes if c else no, verbose_options[i]) for i, c in enumerate(chosen)]
        return opts + ['{}{}'.format('  ', kwargs.get('done', 'done...'))]

    options, verbose_options = prepare_options(args)
    chosen = [False] * len(options)
    index = kwargs.get('idx', 0)

    default = kwargs.get('default', None)
    if isinstance(default, list):
        for idx in default:
            chosen[idx] = True
    if isinstance(default, int):
        chosen[default] = True

    while True:
        try:
            index = one(prompt, *get_verbose_options(verbose_options, chosen), return_index=True, idx=index)
        except QuestionnaireGoBack:
            if any(chosen):
                raise QuestionnaireGoBack(0)
            else:
                raise QuestionnaireGoBack
        if index == len(options):
            return get_options(options, chosen)
        chosen[index] = not chosen[index]
def many ( prompt , * args , * * kwargs ) : def get_options ( options , chosen ) : return [ options [ i ] for i , c in enumerate ( chosen ) if c ] def get_verbose_options ( verbose_options , chosen ) : no , yes = ' ' , '✔' if sys . version_info < ( 3 , 3 ) : no , yes = ' ' , '@' opts = [ '{} {}' . format ( yes if c else no , verbose_options [ i ] ) for i , c in enumerate ( chosen ) ] return opts + [ '{}{}' . format ( '  ' , kwargs . get ( 'done' , 'done...' ) ) ] options , verbose_options = prepare_options ( args ) chosen = [ False ] * len ( options ) index = kwargs . get ( 'idx' , 0 ) default = kwargs . get ( 'default' , None ) if isinstance ( default , list ) : for idx in default : chosen [ idx ] = True if isinstance ( default , int ) : chosen [ default ] = True while True : try : index = one ( prompt , * get_verbose_options ( verbose_options , chosen ) , return_index = True , idx = index ) except QuestionnaireGoBack : if any ( chosen ) : raise QuestionnaireGoBack ( 0 ) else : raise QuestionnaireGoBack if index == len ( options ) : return get_options ( options , chosen ) chosen [ index ] = not chosen [ index ]
Calls `pick` in a while loop to allow user to pick many
    options. Returns a list of chosen options.
Calls pick in a while loop to allow user to pick many options . Returns a list of chosen options .