U
    §¦ºe<	  ã                   @   s&   d Z ddlmZ ddgZddd„ZdS )	z
Interaction
~~~~~~~~~~~
é    )Ú
safe_inputÚconfirmr   NFc           
      C   s²   d}|r|S ddddœ}|| \}}t dƒjf tƒ Ž}d}z8|dkrhd}	|sp|	|k rpt|ƒ}|	d7 }	qHnt|ƒ}W n tk
rˆ   Y dS X |d	kr–d
S |dkr¢dS |dk	r®|S dS )a5  
    A shortcut for typical confirmation prompt.

    :param action:

        a string describing the action, e.g. "Apply changes". A question mark
        will be appended.

    :param default:

        `bool` or `None`. Determines what happens when user hits :kbd:`Enter`
        without typing in a choice. If `True`, default choice is "yes". If
        `False`, it is "no". If `None` the prompt keeps reappearing until user
        types in a choice (not necessarily acceptable) or until the number of
        iteration reaches the limit. Default is `None`.

    :param skip:

        `bool`; if `True`, no interactive prompt is used and default choice is
        returned (useful for batch mode). Default is `False`.

    Usage::

        def delete(key, silent=False):
            item = db.get(Item, args.key)
            if confirm('Delete '+item.title, default=True, skip=silent):
                item.delete()
                print('Item deleted.')
            else:
                print('Operation cancelled.')

    Returns `None` on `KeyboardInterrupt` event.
    é   )ÚyÚn)ÚYr   )r   ÚN)NTFz{action}? ({y}/{n})Né   )Úyesr   r   T)Únor   r   F)ÚstrÚformatÚlocalsÚinputÚKeyboardInterrupt)
ÚactionÚdefaultÚskipZMAX_ITERATIONSÚdefaultsr   r   ÚpromptÚchoiceZcnt© r   úo/mounts/lovelace/software/anaconda3/envs/qiime2-amplicon-2023.9/lib/python3.8/site-packages/argh/interaction.pyr      s4    "ý)NF)Ú__doc__Zargh.ior   Ú__all__r   r   r   r   r   Ú<module>
   s   