
¡\\t  ã               @   sc   d  Z  d d l Z y d d l Z Wn$ e k
 rH d d l j j Z Yn XGd d „  d e ƒ Z d S)z8Provides Tab completion when prompting users for a path.é    Nc               @   sF   e  Z d  Z d Z d d „  Z d d „  Z d d „  Z d d	 „  Z d
 S)Ú	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.

    c             C   s   d  |  _  |  _ |  _ d  S)N)Ú_iterÚ_original_completerÚ_original_delims)Úself© r   ú;/usr/lib/python3/dist-packages/certbot/display/completer.pyÚ__init__   s    zCompleter.__init__c             C   s2   | d k r" t  j | d ƒ |  _ 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)ÚglobZiglobr   Únext)r   ÚtextÚstater   r   r   Úcomplete   s    zCompleter.completec             C   sz   t  j ƒ  |  _ t  j ƒ  |  _ t  j |  j ƒ t  j d ƒ t  j d  k	 ri d t  j k ri t  j	 d ƒ n t  j	 d ƒ d  S)Nz 	
;Úlibeditzbind ^I rl_completeztab: complete)
ÚreadlineZget_completerr   Zget_completer_delimsr   Úset_completerr   Úset_completer_delimsÚ__doc__Úparse_and_bind)r   r   r   r   Ú	__enter__-   s    zCompleter.__enter__c             C   s$   t  j |  j ƒ t  j |  j ƒ d  S)N)r   r   r   r   r   )r   Zunused_typeZunused_valueZunused_tracebackr   r   r   Ú__exit__;   s    zCompleter.__exit__N)Ú__name__Ú
__module__Ú__qualname__r   r	   r   r   r   r   r   r   r   r   
   s
   r   )	r   r   r   ÚImportErrorZcertbot.display.dummy_readlineZdisplayZdummy_readlineÚobjectr   r   r   r   r   Ú<module>   s   