Hacked By AnonymousFox
�
c��f� � �� � d Z ddlZddlZddlZddlZddlZddlZdgZ G d� d� � Zd� Z ddl
Z
e
j e� � j � � ej
d� � � dZdS # e$ r dZY dS w xY w) a1 Word completion for GNU readline.
The completer completes keywords, built-ins and globals in a selectable
namespace (which defaults to __main__); when completing NAME.NAME..., it
evaluates (!) the expression up to the last dot and completes its attributes.
It's very cool to do "import sys" type "sys.", hit the completion key (twice),
and see the list of names defined by the sys module!
Tip: to use the tab key as the completion key, call
readline.parse_and_bind("tab: complete")
Notes:
- Exceptions raised by the completer function are *ignored* (and generally cause
the completion to fail). This is a feature -- since readline sets the tty
device in raw (or cbreak) mode, printing a traceback wouldn't work well
without some complicated hoopla to save, reset and restore the tty state.
- The evaluation of the NAME.NAME... form may cause arbitrary application
defined code to be executed if an object with a __getattr__ hook is found.
Since it is the responsibility of the application (or the user) to enable this
feature, I consider this an acceptable risk. More complicated expressions
(e.g. function calls or indexing operations) are *not* evaluated.
- When the original stdin is not a tty device, GNU readline is never
used, and this module (and the readline module) are silently inactive.
� N� Completerc �. � e Zd Zdd�Zd� Zd� Zd� Zd� ZdS )r Nc � � |r$t |t � � st d� � �|� d| _ dS d| _ || _ dS )a� Create a new completer for the command line.
Completer([namespace]) -> completer instance.
If unspecified, the default namespace where completions are performed
is __main__ (technically, __main__.__dict__). Namespaces should be
given as dictionaries.
Completer instances should be used as the completion mechanism of
readline via the set_completer() call:
readline.set_completer(Completer(my_namespace).complete)
znamespace must be a dictionaryN� r )�
isinstance�dict� TypeError�use_main_ns� namespace)�selfr s �2/opt/alt/python311/lib64/python3.11/rlcompleter.py�__init__zCompleter.__init__* sU � � � >�Z� �4�8�8� >��<�=�=�=�
�� �D���� �D��&�D�N�N�N� c � � | j rt j | _ |� � � s:|dk r2t
r)t
j d� � t
j � � dS dS dS |dk r9d|v r| � |� � | _
n| � |� � | _
| j
| S # t $ r Y dS w xY w)z�Return the next possible completion for 'text'.
This is called successively with state == 0, 1, 2, ... until it
returns None. The completion should begin with 'text'.
r � � N�.)
r
�__main__�__dict__r �strip�_readline_available�readline�insert_text� redisplay�attr_matches�matches�global_matches�
IndexError)r �text�states r
�completezCompleter.completeE s� � � �� /�%�.�D�N��z�z�|�|� ���z�z�&� ��(��.�.�.��&�(�(�(��2��4��t��A�:�:��d�{�{�#�0�0��6�6����#�2�2�4�8�8��� ��<��&�&��� � � ��4�4� ���s �'B4 �4
C�Cc � � t |� � r5|dz
} t j |� � j s|dz
}n# t $ r Y nw xY w|S )N�(�))�callable�inspect� signature�
parameters�
ValueError)r �val�words r
�_callable_postfixzCompleter._callable_postfixd se � ��C�=�=� ��C�K�D�
��(��-�-�8� ��C�K�D����
�
�
���
���� �s �5 �
A�Ac � � g }dh}t |� � }t j t j z D ]M}|d|� |k r=|� |� � |dv r|dz }n |dvr|dz }|� |� � �N| j t j fD ]l}|� � � D ]U\ }}|d|� |k rB||vr>|� |� � |� | �
||� � � � �V�m|S )z�Compute matches when text is a simple name.
Return a list of all keywords, built-in functions and names currently
defined in self.namespace that match.
�__builtins__N> �try�finally�:> �_�None�True�else�pass�False�break�continue� )�len�keyword�kwlist�
softkwlist�add�appendr �builtinsr �itemsr, )r r r �seen�nr+ �nspacer* s r
r zCompleter.global_matcheso s2 � � �������I�I���N�W�%7�7� %� %�D��B�Q�B�x�4�����������-�-�-��#�:�D�D�� "/� /� /� �#�:�D����t�$�$�$���~�x�'8�9� F� F�F�#�\�\�^�^�
F�
F� ��c�����8�t�#�#��D�(8�(8��H�H�T�N�N�N��N�N�4�#9�#9�#�t�#D�#D�E�E�E��
F� �r c �� � t j d|� � }|sg S |� dd� � \ }} t || j � � }n# t
$ r g cY S w xY wt
t |� � � � }|� d� � t |d� � r<|�
d� � |� t |j
� � � � g }t |� � }|dk rd} n|dk rd} nd } |D ]�}
|
d |� |k r�| r|
d |dz � | k s�|�d|
��}t t! t# |� � |
d � � t$ � � r|� |� � �qt! ||
d � � x}�*|� | � ||� � � � ��|� |� � ��|s| sn| dk rd} nd } ��|� � � |S )a� Compute matches when text contains a dot.
Assuming the text is of the form NAME.NAME....[NAME], and is
evaluable in self.namespace, it will be evaluated and its attributes
(as revealed by dir()) are used as possible completions. (For class
instances, class members are also considered.)
WARNING: this can still invoke arbitrary C code, if an object
with a __getattr__ hook is evaluated.
z(\w+(\.\w+)*)\.(\w*)r � r. � __class__r r2 �__NTr )�re�match�group�evalr � Exception�set�dir�discard�hasattrr? �update�get_class_membersrH r; r �getattr�type�propertyr@ r, �sort)
r r �m�expr�attr�
thisobject�wordsr rD �noprefixr+ rK �values
r
r zCompleter.attr_matches� s: � �
�H�,�d�3�3��� ��I��W�W�Q��]�]�
��d� ��d�D�N�3�3�J�J��� � � ��I�I�I� ���� �C�
�O�O�$�$��
�
�
�n�%�%�%��:�{�+�+� B��I�I�k�"�"�"��L�L�*�:�+?�@�@�A�A�A�����I�I���2�:�:��H�H�
�S�[�[��H�H��H� ��
.�
.����!��H��$�$�!� %�&*�4�A�a�C�4�j�H�&<�&<�'+�t�t�T�T�2�E�!�'�$�z�*:�*:�D�$�"G�"G�"*�,� ,� !� ���u�-�-�-� �!(��T�4�!@�!@�@��M����t�'=�'=�e�U�'K�'K�L�L�L�L����u�-�-�-���
�h�
���3��������1 �2 �������s �A
�
A�A�N)�__name__�
__module__�__qualname__r r! r, r r � r r
r r ) sd � � � � � �'� '� '� '�6� � �> � � �� � �6>� >� >� >� >r c �| � t | � � }t | d� � r| j D ]}|t |� � z }�|S )N� __bases__)rP rR rf rT )�klass�ret�bases r
rT rT � sJ � �
�e�*�*�C��u�[�!�!� 0��O� 0� 0�D��)�$�/�/�/�C�C��Jr c �* � t j d � � S r` )r �
set_completerrd r r
�<lambda>rl � s � �H�2�4�8�8� r TF)�__doc__�atexitrA r&