%PDF- %PDF-
Direktori : /lib/python3.12/__pycache__/ |
Current File : //lib/python3.12/__pycache__/rlcompleter.cpython-312.pyc |
� ���f� � �� � d Z ddlZddlZddlZddlZddlZddlZdgZ G d� d� Zd� Z ddl Z e j e� j � ej d� � dZy# e$ r dZY yw 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� Zy)r Nc �n � |rt |t � st d� �|�d| _ yd| _ || _ y)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 �"/usr/lib/python3.12/rlcompleter.py�__init__zCompleter.__init__* s; � � �Z� �4�8��<�=�=� �� �D�� �D��&�D�N� c �| � | j rt j | _ |j � s7|dk( r1t r*t j d� t j � yyy|dk( r1d|v r| j |� | _ n| j |� | _ | j | S # t $ r Y yw 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�&��(�(��.��&�&�(�����A�:��d�{�#�0�0��6���#�2�2�4�8��� ��<�<��&�&��� �� �s � B/ �/ B;�:B;c � � t |� r,|dz } t j |� j s|dz }|S |S # t $ r Y |S w xY w)N�(�))�callable�inspect� signature� parameters� ValueError)r �val�words r �_callable_postfixzCompleter._callable_postfixd sX � ��C�=��C�K�D� ��(�(��-�8�8��C�K�D� ��t��� � ���� �s �$: � A�Ac �� � g }dh}t |� }t j t j z D ]@ }|d| |k( s�|j |� |dv r|dz }n |dvr|dz }|j |� �B | j t j fD ]Z }|j � D ]E \ }}|d| |k( s�||vs�|j |� |j | j ||� � �G �\ |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 s � � �������I���N�N�W�%7�%7�7� %�D��B�Q�x�4��������-�-��#�:�D�� "/� /� �#�:�D����t�$� %� �~�~�x�'8�'8�9� F�F�#�\�\�^� F� ��c����8�t�#��D�(8��H�H�T�N��N�N�4�#9�#9�#�t�#D�E� F� F� �r c �: � t j d|� }|sg S |j dd� \ }} t || j � }t t |� � }|j d� t |d� r5|j d� |j t |j � � g }t |� }|dk( rd} n |dk( rd} nd } |D ]� } | d | |k( s�| r| d |dz | k( r�|�d | ��}t t! t# |� | d � t$ � r|j'