3 Ú¯aU ã @s¦dZddlZddlmZddlmZddlmZddlmZddlmZddlm Z e rddd l m Z y ddl Z Wn"e k r’ddljjjZ YnXGd d „d ƒZdS) z8Provides Tab completion when prompting users for a path.éN)Ú TracebackType)ÚCallable)ÚIterator)ÚOptional)ÚType)Ú TYPE_CHECKING)ÚLiteralc@sfeZdZdZddœdd„Zeeeedœdd„Zddœd d „Z ee e ee ee d d œ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)ÚreturncCs|||dS)N©)Úselfr r ú/usr/lib/python3.6/completer.pyÚ__init__%szCompleter.__init__)ÚtextÚstater cCs$|dkrtj|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 rrr r r Úcomplete*s zCompleter.completecCsXtjƒ|_tjƒ|_tj|jƒtjdƒtjdk rJdtjkrJtj dƒn tj dƒdS)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__9s     zCompleter.__enter__zLiteral[False])Ú unused_typeÚ unused_valueÚunused_tracebackr cCstj|jƒtj|jƒdS)NF)rrrrr)r rrr r r r Ú__exit__Gs  zCompleter.__exit__)Ú__name__Ú __module__Ú __qualname__rrÚstrÚintrrrrÚ BaseExceptionrr!r r r r r s r )rrÚtypesrZtypingrrrrrZtyping_extensionsrrÚ ImportErrorZ(certbot._internal.display.dummy_readlineZ _internalZdisplayZdummy_readliner r r r r Ús