
    M/e
                         d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 	 ddl
Z
 G d	 d
      Zy# e$ r ddlmc mc mZ
 Y w xY w)z8Provides Tab completion when prompting users for a path.    N)TracebackType)Callable)Iterator)Literal)Optional)Typec                   j    e Zd ZdZddZdededee   fdZddZ	d	ee
e      d
ee   dee   ddfdZy)	Completera/  Provides Tab completion when prompting users for a path.

    This class is meant to be used with readline to provide Tab
    completion for users entering paths. The complete method can be
    passed to readline.set_completer directly, however, this function
    works best as a context manager. For example:

    with Completer():
        raw_input()

    In this example, Tab completion will be available during the call to
    raw_input above, however, readline will be restored to its previous
    state when exiting the body of the with statement.

    returnNc                     |  |  |  y )N selfs    E/usr/lib/python3/dist-packages/certbot/_internal/display/completer.py__init__zCompleter.__init__"   s        textstatec                 r    |dk(  rt        j                  |dz         | _        t        | j                  d      S )a(  Provides path completion for use with readline.

        :param str text: text to offer completions for
        :param int state: which completion to return

        :returns: possible completion for text or ``None`` if all
            completions have been returned
        :rtype: str

        r   *N)globiglob_iternext)r   r   r   s      r   completezCompleter.complete'   s0     A:D3J/DJDJJ%%r   c                 j   t        j                         | _        t        j                         | _        t        j
                  | j                         t        j                  d       t         j                  (dt         j                  v rt        j                  d       y t        j                  d       y )Nz 	
;libeditzbind ^I rl_completeztab: complete)
readlineget_completer_original_completerget_completer_delims_original_delimsset_completerr   set_completer_delims__doc__parse_and_bindr   s    r   	__enter__zCompleter.__enter__6   s|    #+#9#9#;  ( = = ?t}}-%%h/ 'I9I9I,I##$9:##O4r   unused_typeunused_valueunused_tracebackzLiteral[False]c                     t        j                  | j                         t        j                  | j                         y)NF)r   r$   r"   r#   r    )r   r(   r)   r*   s       r   __exit__zCompleter.__exit__D   s/     	%%d&;&;<t778r   )r   N)__name__
__module____qualname__r%   r   strintr   r   r'   r   BaseExceptionr   r,   r   r   r   r
   r
      sg     #
&S & &# &5HT--@$A '6#+M#:?Or   r
   )r%   r   typesr   typingr   r   r   r   r   r   ImportError(certbot._internal.display.dummy_readline	_internaldisplaydummy_readliner
   r   r   r   <module>r:      sI    >       @
8 8	  @??@s   ; AA