ó
Á£ô_c           @   se   d  Z  d d l Z y d d l Z Wn& e k
 rJ d d l j j j Z n Xd e f d „  ƒ  YZ	 d S(   s8   Provides Tab completion when prompting users for a path.iÿÿÿÿNt	   Completerc           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   s/  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(   t   Nonet   _itert   _original_completert   _original_delims(   t   self(    (    sG   /usr/lib/python2.7/site-packages/certbot/_internal/display/completer.pyt   __init__   s    c         C   s5   | d k r% t  j | d ƒ |  _ n  t |  j d ƒ S(   s(  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

        i    t   *N(   t   globt   iglobR   t   nextR   (   R   t   textt   state(    (    sG   /usr/lib/python2.7/site-packages/certbot/_internal/display/completer.pyt   complete   s    c         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(   Ns    	
;t   libedits   bind ^I rl_completes   tab: complete(   t   readlinet   get_completerR   t   get_completer_delimsR   t   set_completerR   t   set_completer_delimst   __doc__R   t   parse_and_bind(   R   (    (    sG   /usr/lib/python2.7/site-packages/certbot/_internal/display/completer.pyt	   __enter__.   s    c         C   s$   t  j |  j ƒ t  j |  j ƒ d  S(   N(   R   R   R   R   R   (   R   t   unused_typet   unused_valuet   unused_traceback(    (    sG   /usr/lib/python2.7/site-packages/certbot/_internal/display/completer.pyt   __exit__<   s    (   t   __name__t
   __module__R   R   R   R   R   (    (    (    sG   /usr/lib/python2.7/site-packages/certbot/_internal/display/completer.pyR       s
   			(
   R   R   R   t   ImportErrort(   certbot._internal.display.dummy_readlinet	   _internalt   displayt   dummy_readlinet   objectR    (    (    (    sG   /usr/lib/python2.7/site-packages/certbot/_internal/display/completer.pyt   <module>   s   