3
Ú¯aU
ã @ s¦ d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z e rddd l
mZ yddlZW n" e
k
r’ ddljjjZY nX G d
d„ dƒZdS )z8Provides Tab completion when prompting users for a path.é N)Ú
TracebackType)ÚCallable)ÚIterator)ÚOptional)ÚType)Ú
TYPE_CHECKING)ÚLiteralc @ sf e Zd ZdZddœdd„Zeeee dœdd„Zddœd d
„Z ee
e ee ee ddœd
d„Z
dS )Ú 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.
N)Úreturnc C s | | | d S )N© )Úselfr r ú/usr/lib/python3.6/completer.pyÚ__init__% s zCompleter.__init__)ÚtextÚstater
c C s$ |dkrt j|d ƒ| _t| jdƒ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)ÚglobZiglobZ_iterÚnext)r r r r r r
Úcomplete* s zCompleter.completec C sX t jƒ | _t jƒ | _t j| jƒ t jdƒ t jd k rJdt jkrJt j dƒ n
t j dƒ d S )Nz
;Úlibeditzbind ^I rl_completez
tab: complete)
ÚreadlineZ
get_completerÚ_original_completerZget_completer_delimsÚ_original_delimsÚ
set_completerr Úset_completer_delimsÚ__doc__Úparse_and_bind)r r r r
Ú __enter__9 s
zCompleter.__enter__zLiteral[False])Úunused_typeÚunused_valueÚunused_tracebackr
c C s t j| jƒ t j| jƒ dS )NF)r r r r r )r r r r r r r
Ú__exit__G s zCompleter.__exit__)Ú__name__Ú
__module__Ú__qualname__r r ÚstrÚintr r r r Ú
BaseExceptionr r! r r r r
r s
r )r r Útypesr Ztypingr r r r r Ztyping_extensionsr r ÚImportErrorZ(certbot._internal.display.dummy_readlineZ _internalZdisplayZdummy_readliner r r r r
Ú