
    BNeE                    l    d dl mZ d dlmZmZ d dlmZ d dlmZm	Z	 ddl
mZ dgZ G d de	          Zd	S )
    )annotations)CallableOptional)Document)ValidationError	Validator   )unindent_codePythonValidatorc                  $    e Zd ZdZdddZdd
ZdS )r   z
    Validation of Python input.

    :param get_compiler_flags: Callable that returns the currently
        active compiler flags.
    Nget_compiler_flagsCallable[[], int] | NonereturnNonec                    || _         d S N)r   )selfr   s     |/home/feoh/.cache/pypoetry/virtualenvs/veilid-python-play-bIboZq2W-py3.11/lib/python3.11/site-packages/ptpython/validator.py__init__zPythonValidator.__init__   s    "4    documentr   c                F   t          |j                  }|                    d          rdS |                                                    d          rdS 	 | j        r|                                 }nd}t          |dd|d           dS # t          $ rB}|                    |j        pd	d	z
  |j	        pd	d	z
            }t          |d
|           d}~wt          $ r"}t          dt          |                    d}~wt          $ r}t          dd|z            d}~ww xY w)z7
        Check input for Python syntax errors.
        N!r   z<input>execT)flagsdont_inheritr	   zSyntax Error: zSyntax Error: %s)r
   text
startswithlstripr   compileSyntaxErrortranslate_row_col_to_indexlinenooffsetr   	TypeErrorstr
ValueError)r   r   r   r   eindexs         r   validatezPythonValidator.validate   s`    X]++ ??6"" 	F ;;==##C(( 	F	=& //11D)V5tLLLLLL 	? 	? 	?
 77Q!#ahm!q%8 E "%)=!)=)=>>> 	- 	- 	-!!SVV,,, 	= 	= 	= "!%7!%;<<<	=s0   2B
 

D =CD C;;D DD r   )r   r   r   r   )r   r   r   r   )__name__
__module____qualname____doc__r   r+    r   r   r   r      sK         5 5 5 5 5&= &= &= &= &= &=r   N)
__future__r   typingr   r   prompt_toolkit.documentr   prompt_toolkit.validationr   r   utilsr
   __all__r   r0   r   r   <module>r7      s    " " " " " " % % % % % % % % , , , , , , @ @ @ @ @ @ @ @            
1= 1= 1= 1= 1=i 1= 1= 1= 1= 1=r   