TL iHfdZddlZddlmZddlZddlZddlZddlZddlZddl m Z dZ edfdZ dZ y)z Utilities for end-users. N) namedtuple) InterpreterFctr&tjddtjGfdd} ddl}ddl}|j |j|jd|jd |jd |jd |jd |jd y#t$rtdYywxYw)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)filenamefilemodelevelceZdZfdZy)setup_readline..JediRLc|dk(rtjjdtj t j dt|zt|jg}|j}t j d||Dcgc]*}|dt||jz |jz,c}|_ tjj%d |j|Scc}w#t jdt!j"zxYw#tjj%dwxYw#t&$rYywxYw)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: %sNzREPL Completion error: )syspathinsertosgetcwdloggingdebugreprr__dict__completelen_like_name_lengthname_with_symbolsmatcheserror traceback format_excpop IndexError)selftextstate interpreter completionscr namespace_modules P/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/jedi/utils.pyrz'setup_readline..JediRL.completeEs'z299;/$MM";d4j"HI"-d5E5N5N4O"PK"-"6"6U"6"CKMM"8+F"-$=c$i!*=*==>ATATT$DLHHLLO ||E**$MM"? HI%%b) 6 456sC C#"C#c tdd}ddlm}tjd|}|t |Dcgc]\}}|dk(r|n t |c}}Scc}}w)z_ Returns a namedtuple of Jedi's version, similar to Python's ``sys.version_info``. Versionzmajor, minor, micror) __version__z [a-z]+|\d+)rjedir<refindall enumerateint)r;r<tuplixs r( version_inforF~sT $9:G ::m[ 1D 4IA!q&Qc!f,I JJIsA )__doc____main__ collectionsrrrr?rrr>rr/r9rFr-r(rKs?" %-Eh*VKr-