ó
±xYc           @  sV   d  d l  m Z d  d l m Z d  d l m Z m Z d Z d e f d „  ƒ  YZ d S(	   iÿÿÿÿ(   t   unicode_literals(   t   string_types(   t	   Completert
   Completionu   WordCompletert   WordCompleterc           B  s/   e  Z d  Z e d e e e d „ Z d „  Z RS(   u¿  
    Simple autocompletion on a list of words.

    :param words: List of words.
    :param ignore_case: If True, case-insensitive completion.
    :param meta_dict: Optional dict mapping words to their meta-information.
    :param WORD: When True, use WORD characters.
    :param sentence: When True, don't complete by comparing the word before the
        cursor, but by comparing all the text before the cursor. In this case,
        the list of words is just a list of strings, where each string can
        contain spaces. (Can not be used together with the WORD option.)
    :param match_middle: When True, match not only the start, but also in the
                         middle of the word.
    c         C  sx   | o	 | s t  ‚ t | ƒ |  _ | |  _ | p4 i  |  _ | |  _ | |  _ | |  _ t d „  |  j Dƒ ƒ st t  ‚ d  S(   Nc         s  s   |  ] } t  | t ƒ Vq d  S(   N(   t
   isinstanceR   (   t   .0t   w(    (    sE   lib/python2.7/site-packages/prompt_toolkit/contrib/completers/base.pys	   <genexpr>$   s    (	   t   AssertionErrort   listt   wordst   ignore_caset	   meta_dictt   WORDt   sentencet   match_middlet   all(   t   selfR
   R   R   R   R   R   (    (    sE   lib/python2.7/site-packages/prompt_toolkit/contrib/completers/base.pyt   __init__   s    				c         #  s«   ˆ  j  r | j ‰ n | j d ˆ  j ƒ ‰ ˆ  j rB ˆ j ƒ  ‰ n  ‡  ‡ f d †  } xP ˆ  j D]E } | | ƒ r^ ˆ  j j | d ƒ } t	 | t
 ˆ ƒ d | ƒVq^ q^ Wd  S(   NR   c           s<   ˆ  j  r |  j ƒ  }  n  ˆ  j r+ ˆ |  k S|  j ˆ ƒ Sd S(   u/    True when the word before the cursor matches. N(   R   t   lowerR   t
   startswith(   t   word(   R   t   word_before_cursor(    sE   lib/python2.7/site-packages/prompt_toolkit/contrib/completers/base.pyt   word_matches0   s
    		
u    t   display_meta(   R   t   text_before_cursort   get_word_before_cursorR   R   R   R
   R   t   getR   t   len(   R   t   documentt   complete_eventR   t   aR   (    (   R   R   sE   lib/python2.7/site-packages/prompt_toolkit/contrib/completers/base.pyt   get_completions&   s    		
N(   t   __name__t
   __module__t   __doc__t   Falset   NoneR   R    (    (    (    sE   lib/python2.7/site-packages/prompt_toolkit/contrib/completers/base.pyR      s   	N(   u   WordCompleter(	   t
   __future__R    t   sixR   t   prompt_toolkit.completionR   R   t   __all__R   (    (    (    sE   lib/python2.7/site-packages/prompt_toolkit/contrib/completers/base.pyt   <module>   s   