uBFjHhdZddlZddlmZddlZddlZddlZddlZddlZddl m Z dZ edfdZ dZ dS)z Utilities for end-users. N) namedtuple) InterpreterFc tr!tjddtjGfdd} ddl}ddl}||j|d|d |d |d |d | d dS#t$rtdYdSwxYw)a This function sets up :mod:`readline` to use Jedi in a Python interactive shell. If you want to use a custom ``PYTHONSTARTUP`` file (typically ``$HOME/.pythonrc.py``), you can add this piece of code:: try: from jedi.utils import setup_readline except ImportError: # Fallback to the stdlib readline completer if it is installed. # Taken from http://docs.python.org/2/library/rlcompleter.html print("Jedi is not installed, falling back to readline") try: import readline import rlcompleter readline.parse_and_bind("tab: complete") except ImportError: print("Readline is not installed either. No tab completion is enabled.") else: setup_readline() This will fallback to the readline completer if Jedi is not installed. The readline completer will only complete names in the global namespace, so for example:: ran will complete to ``range``. With Jedi the following code:: range(10).cou will complete to ``range(10).count``, this does not work with the default cPython :mod:`readline` completer. You will also need to add ``export PYTHONSTARTUP=$HOME/.pythonrc.py`` to your shell profile (usually ``.bash_profile`` or ``.profile`` if you use bash). z /tmp/jedi.loga)filenamefilemodelevelceZdZfdZdS)setup_readline..JediRLc|dkrtjdtj t jdtztj g}| }t jd|fd|D|_ n.#t j dtjzxYw tjdn$#tjdwxYw |j |S#t $rYdSwxYw)a This complete stuff is pretty weird, a generator would make a lot more sense, but probably due to backwards compatibility this is still the way how it works. The only important part is stuff in the ``state == 0`` flow, everything else has been copied from the ``rlcompleter`` std. library module. rzStart REPL completion: )fuzzyzREPL completions: %sc^g|])}dt|jz |jz*S)N)len_like_name_lengthname_with_symbols).0ctexts 8C:\PYTHON\_runtimes\venv\Lib\site-packages\jedi/utils.py z;setup_readline..JediRL.complete..YsJ$$$=c$ii!*===>ATT$$$zREPL Completion error: N)syspathinsertosgetcwdloggingdebugreprr__dict__completematcheserror traceback format_excpop IndexError)selfrstate interpreter completionsr namespace_modules ` rr!z'setup_readline..JediRL.completeEsFzz29;;///$M";d4jj"HIII"-d5E5N4O"P"PK"-"6"6U"6"C"CKM"8+FFF$$$$!,$$$DLLM"??? HIII%%b))))) 666 45555556sC&&DDctdd}ddlm}tjd|}|dt |DS)z_ Returns a namedtuple of Jedi's version, similar to Python's ``sys.version_info``. Versionzmajor, minor, micror) __version__z [a-z]+|\d+cBg|]\}}|dkr|nt|S))int)rixs rrz version_info..s.IIIA!q&&QQc!ffIIIr)rjedir?refindall enumerate)r>r?tupls r version_inforJ~sY $9::G      :m[ 1 1D 7II4III JJr)__doc____main__ collectionsrrr$rFrrrErr2r<rJrrrOs"""""" %-Eh*h*h*h*VKKKKKr