Ë
    ½lÔhH  ã                   óf   — d Z ddlZddlmZ ddlZddlZddlZddlZddlZddl	m
Z
 dZedfd„Zd„ Zy)z
Utilities for end-users.
é    N)Ú
namedtuple)ÚInterpreterFc                 óÌ  ‡ ‡— t         r&t        j                  ddt        j                  ¬«        G ˆˆ fd„d«      }	 ddl}ddl}|j                   |«       j                  «       |j                  d«       |j                  d	«       |j                  d
«       |j                  d«       |j                  d«       |j                  d«       y# t        $ r t        d«       Y yw xY w)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<TAB>

    will complete to ``range``.

    With Jedi the following code::

        range(10).cou<TAB>

    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.logÚa)ÚfilenameÚfilemodeÚlevelc                   ó   •— e Zd Zˆ ˆfd„Zy)úsetup_readline.<locals>.JediRLc                 óÚ  •— |dk(  rît         j                  j                  dt        j                  «       «       	 t        j                  dt        |«      z   «       t        |‰j                  g«      }|j                  ‰¬«      }t        j                  d|«       |D �cg c]*  }|dt        |«      |j                  z
   |j                  z   ‘Œ, c}| _        	 t         j                  j%                  d«       	 | j                  |   S c c}w #  t        j                  dt!        j"                  «       z   «       ‚ xY w# t         j                  j%                  d«       w xY w# t&        $ r Y yw xY w)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.
            r   zStart REPL completion: )ÚfuzzyzREPL completions: %sNzREPL Completion error:
)ÚsysÚpathÚinsertÚosÚgetcwdÚloggingÚdebugÚreprr   Ú__dict__ÚcompleteÚlenÚ_like_name_lengthÚname_with_symbolsÚmatchesÚerrorÚ	tracebackÚ
format_excÚpopÚ
IndexError)ÚselfÚtextÚstateÚinterpreterÚcompletionsÚcr   Únamespace_modules         €€ú_/home/josh/.local/share/pipx/venvs/python-lsp-server/lib/python3.12/site-packages/jedi/utils.pyr   z'setup_readline.<locals>.JediRL.completeE   s'  ø€ ð ˜ŠzÜ—‘—‘ ¤2§9¡9£;Ô/ð$Ü—M‘MÐ";¼dÀ4»jÑ"HÔIÜ"-¨dÐ5E×5NÑ5NÐ4OÓ"P�Kà"-×"6Ñ"6¸UÐ"6Ó"C�KÜ—M‘MÐ"8¸+ÔFð "-ö$àð Ð=œc $›i¨!×*=Ñ*=Ñ=Ð>À×ATÑATÓTò$�D•Lô —H‘H—L‘L ”OðØ—|‘| EÑ*Ð*ùò$øðÜ—M‘MÐ"<¼y×?SÑ?SÓ?UÑ"UÔVØûä—H‘H—L‘L •Oûô ò Ùðús<   ºA$D
 Â/DÃD
 Ã6E ÄD
 Ä
-D7Ä7D: Ä:!EÅ	E*Å)E*N)Ú__name__Ú
__module__Ú__qualname__r   )r   r'   s   €€r(   ÚJediRLr   D   s   ø„ ö 	ó    r,   r   Nztab: completezset completion-ignore-case onzset show-all-if-unmodifiedzset show-all-if-ambiguous onz&set completion-prefix-display-length 2Ú z$Jedi: Module readline not available.)ÚREADLINE_DEBUGr   ÚbasicConfigÚDEBUGÚrlcompleterÚreadlineÚset_completerr   Úparse_and_bindÚset_completer_delimsÚImportErrorÚprint)r'   r   r,   r2   r3   s   ``   r(   Úsetup_readliner9      sÆ   ù€ õT Ü×ÑØ$ØÜ—-‘-õ	
÷!ô !ðF*ó
 	Ûð 	×Ñ™v›x×0Ñ0Ô1Ø×Ñ Ô0à×ÑÐ ?Ô@à×ÑÐ <Ô=Ø×ÑÐ >Ô?à×ÑÐ HÔIà×%Ñ% bÕ)øô ò 6ÜÐ4Ö5ð6ús   ½C ÃC#Ã"C#c            	      óÀ   — t        dd«      } ddlm} t        j                  d|«      } | t        |«      D ��cg c]  \  }}|dk(  r|n
t        |«      ‘Œ c}}Ž S c c}}w )z_
    Returns a namedtuple of Jedi's version, similar to Python's
    ``sys.version_info``.
    ÚVersionzmajor, minor, micror   )Ú__version__z
[a-z]+|\d+é   )r   Újedir<   ÚreÚfindallÚ	enumerateÚint)r;   r<   ÚtuplÚiÚxs        r(   Úversion_inforF   ~   sT   € ô
 ˜Ð$9Ó:€GÝ Ü�:‰:�m [Ó1€DÙ¼À4»×I±°°A˜!˜qš&‘Q¤c¨!£fÑ,ÓIÐJÐJùÓIs   ¹A
)Ú__doc__Ú__main__Úcollectionsr   r   r   r?   r   r   r>   r   r/   r9   rF   © r-   r(   ú<module>rK      s?   ðñó Ý "Û Û Û 	Û 	Û 
å ð €ð %-°Eó h*óVKr-   