| Server IP : 217.160.0.135 / Your IP : 216.73.217.85 Web Server : Apache System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64 User : sws1074145052 ( 1074145052) PHP Version : 8.3.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /lib/python3/dist-packages/jedi/__pycache__/ |
Upload File : |
�
p�{c` � �h � d Z ddlZddlmZ ddlZddlZddlZddlZddlZddl m
Z
dZedfd�Zd� Z
dS )z
Utilities for end-users.
� N)�
namedtuple)�InterpreterFc � � �� t r!t j ddt j �� � G �� fd�d� � } ddl}ddl}|� |� � j � � |� d� � |� d � � |� d
� � |� d� � |� d� � |� d
� � dS # t $ r t d� � Y dS w xY 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 Zd Z� �fd�ZdS )�setup_readline.<locals>.JediRLc � ��� |dk �rt j � dt j � � � � t j dt �� � z � � t ��j g� � }|�
��� � }t j d|� � �fd�|D � � | _ n.# t j dt j � � z � � � xY w t j � d� � n$# t j � d� � w xY w | j | S # t $ r Y dS w xY 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 zStart REPL completion: )�fuzzyzREPL completions: %sc �^ �� g | ])}�d t �� � |j z
� |j z ��*S )N)�len�_like_name_length�name_with_symbols)�.0�c�texts ��,/usr/lib/python3/dist-packages/jedi/utils.py�
<listcomp>z;setup_readline.<locals>.JediRL.complete.<locals>.<listcomp>Y sJ �� � $� $� $�� �=�c�$�i�i�!�*=�=�=�>��AT�T�$� $� $� zREPL Completion error:
N)�sys�path�insert�os�getcwd�logging�debug�reprr �__dict__�complete�matches�error� traceback�
format_exc�pop�
IndexError)�selfr �state�interpreter�completionsr
�namespace_modules ` ��r r! z'setup_readline.<locals>.JediRL.completeE sF ��� � ��z�z������2�9�;�;�/�/�/�$��M�";�d�4�j�j�"H�I�I�I�"-�d�5E�5N�4O�"P�"P�K�"-�"6�"6�U�"6�"C�"C�K��M�"8�+�F�F�F�$� $� $� $�!,�$� $� $�D�L�L����M�"<�y�?S�?U�?U�"U�V�V�V�����
!� �H�L�L��O�O�O�O��C�H�L�L��O�O�O�O����
��|�E�*�*���
�
�
��t�t�
���s0 �A8B5 �4D �5+C � D �!D%�)D6 �6
E�EN)�__name__�
__module__�__qualname__r! )r
r, s ��r �JediRLr D s3 �� � � � � � � � � � � � � r r0 r Nz
tab: completezset completion-ignore-case onzset show-all-if-unmodifiedzset 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
r0 r5 r6 s `` r �setup_readliner<