Format: application/x-python-code
1 o
2
3 ��h� � @ sd d Z ddlZddlZddlmZ ddlmZ ddlmZ e� dej
4 �Zddd�ZG d d
5 � d
6 e
7 �ZdS )z�
8 Simple utility for splitting user input. This is used by both inputsplitter and
9 prefilter.
10
11 Authors:
12
13 * Brian Granger
14 * Fernando Perez
15 � N)� py3compat)�get_stream_enc)�OInfoaV
16 ^(\s*) # any leading space
17 ([,;/%]|!!?|\?\??)? # escape character or characters
18 \s*(%{0,2}[\w\.\*]*) # function/method, possibly with leading %
19 # to correctly treat things like '?%magic'
20 (.*?$|$) # rest of line
21 c C s� t tjd�}t�| |�} |du rt}|�| �}|s?z
22 | �dd�\}}W n ty1 | d}}Y nw t �d| ��
23 � d }d}n|�
24 � \}}}}||pKd|�� |fS )z`Split user input into initial whitespace, escape character, function part
25 and the rest.
26 zutf-8N� � z
27 ^(\s*)(.*)r )r �sys�stdinr Zcast_unicode�
28 line_split�match�split�
29 ValueError�re�groups�strip)�line�pattern�encodingr
30 �ifun�the_rest�pre�esc� r �Mc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/core/splitinput.py�split_user_input6 s
31 �r c @ s8 e Zd ZdZd
32 dd�Zdefdd�Zdd � Zd
33 d� ZdS )�LineInfoa{ A single line of input and associated info.
34
35 Includes the following as properties:
36
37 line
38 The original, raw line
39
40 continue_prompt
41 Is this line a continuation in a sequence of multiline input?
42
43 pre
44 Any leading whitespace.
45
46 esc
47 The escape character(s) in pre or the empty string if there isn't one.
48 Note that '!!' and '??' are possible values for esc. Otherwise it will
49 always be a single character.
50
51 ifun
52 The 'function part', which is basically the maximal initial sequence
53 of valid python identifiers and the '.' character. This is what is
54 checked for alias and magic transformations, used for auto-calling,
55 etc. In contrast to Python identifiers, it may start with "%" and contain
56 "*".
57
58 the_rest
59 Everything else on the line.
60
61 raw_the_rest
62 the_rest without whitespace stripped.
63 Fc C sX || _ || _t|�\| _| _| _| _| j�� | _| j� � | _
64 | j
65 r&d| _d S | j| _d S )Nr )r �continue_promptr r r r Zraw_the_rest�lstripr r Zpre_charZpre_whitespace)�selfr r r r r �__init__r s
66 zLineInfo.__init__�returnc C s |� | j�S )a Do a full, attribute-walking lookup of the ifun in the various
67 namespaces for the given IPython InteractiveShell instance.
68
69 Return a dict with keys: {found, obj, ospace, ismagic}
70
71 Note: can cause state changes because of calling getattr, but should
72 only be run if autocall is on and if the line hasn't matched any
73 other, less dangerous handlers.
74
75 Does cache the results of the call, so can be called multiple times
76 without worrying about *further* damaging state.
77 )Z_ofindr )r �ipr r r �ofind~ s
78 zLineInfo.ofindc C s d| j | j| j| jf S )NzLineInfo [%s|%s|%s|%s])r r r r �r r r r �__str__� s zLineInfo.__str__c C s dt | � d S )N�<�>)�strr"