
    fH                     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(  rt         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         E/var/www/cvtools/html/venv/lib/python3.12/site-packages/jedi/utils.pyr   z'setup_readline.<locals>.JediRL.completeE   s'    z299;/$MM";d4j"HI"-d5E5N5N4O"PK"-"6"6U"6"CKMM"8+F "-$ =c$i!*=*==>ATATT$DL HHLLO||E**$MM"<y?S?S?U"UVHHLL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*
 	 	vx0010 ?@ <= >? HI%%b)  6456s   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[1D4IA!q&Qc!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-   