wL idZddlZddlmZddlmZmZmZddlmZm Z ddl m Z ddl m Z ddl mZdd lmZddlmZddlZddlZddlZeZd ed efd Zd ed eded efdZd ed ed efdZdZGddeZGdde Z y)zfprompt-toolkit utilities Everything in this module is a private API, not to be used outside IPython. N)wcwidth)provisionalcompletercursor_to_position_deduplicate_completions) Completer Completion)Lexer) PygmentsLexer) patch_stdout) get_ipythonstringreturnc|jdd}|jdd}t||kr|S|jd}|jtj}|ddk(r|j t|dkDr&d j |d |d d d |d dd |dSt|dkDrNdtjzdztjzdzj |d |d d d |d dd |dS|S)a If a string is long enough, and has at least 3 dots, replace the middle part with ellipses. If a string naming a file is long enough, and has at least 3 slashes, replace the middle part with ellipses. If three consecutive dots, or two consecutive dots are encountered these are replaced by the equivalents HORIZONTAL ELLIPSIS or TWO DOT LEADER unicode equivalents z...…z..u‥.u {}.{}…{}.{}rNz{}u{}…{})replacelensplitosseppopformat)r min_elide object_parts file_partss ^/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/IPython/terminal/ptutils.py _elide_pointr"s$^^E";    Mtypedrct||kr|St|dz }|dkr|S|j|r$t|t|kDr |ddd||dS|S)zT Elide the middle of a long string if the beginning has already been typed. rNr)r startswith)r r$r cut_how_muchs r! _elide_typedr)Esq  6{Y u:a| | td||_||_y)Nz/Please pass shell=an InteractiveShell instance.) TypeError_ipy_completershell)self ipy_completerr9s r!__init__zIPythonPTCompleter.__init__ds' =]2MN N+ r#c^|jr |jS|jjS)N)r8r9r)r:s r!r;z IPythonPTCompleter.ipy_completerjs'   && &::'' 'r#c#LK|jjsyt5t5|j}|j }|j }|j}t|||} |j||||jEd{ddddddy7#t$rU} tj\} } } tj| | | n#t $rt#dYnwxYwYd}~ld}~wwxYw#1swYuxYw#1swYyxYww)Nz"Unrecoverable Error in completions) current_linestripr rr0cursor_position_rowcursor_position_colcursor_positionr_get_completionsr; Exceptionsysexc_info tracebackprint_exceptionAttributeErrorprint) r:documentcomplete_eventr1 cursor_row cursor_colrCr2eexc_type exc_valueexc_tbs r!get_completionsz"IPythonPTCompleter.get_completionsqs$$**,  ^ @13 @==D!55J!55J&66O'j*EF @00vPTPbPbccc @ @ @d @@25,,./Hi--h 6J%@>?@  @ @ @ @ @s&D$ D>D 2!B+B)B+D D$)B++ D 5/C%$D%C< 9D;C< <D?D D  D  D DD!D$c #Kt|dd}t||j||}|D]}|jst j d|j}t |ddk(rn||jzdkDr\||jdz } t j d| |z} t |dddk(r t| |j|z dz |j} t|j||} |jdn|jj} |jd k(r]t| |j|z t| d z||j|j| |j|jz ct| |j|z t| ||j|j| |j yw) zT Private equivalent of get_completions() use only for unit_testing. debugFNFCrr)start_positionNfunctionz()r+)rXdisplay display_meta)getattrr completionsr0 unicodedata normalizerstartrr3r9rtyper,end signature)r:r1r2rCipycrVr^cr0 char_before fixed_text display_text adjusted_textrs r!rDz#IPythonPTCompleter._get_completionssgu-. $""402 4 A66((7D tAw1$"QWW,q0"&qww{"3K!,!6!6{T1"3JtAay)Q.(AGGfDTWXDXYY 66LDfM#jj0djj6J6JIvv# !#$77V#3"$t+QWWquu-"+ "#!++!5  !!#$77V#3"$QWWquu-"+ "#  W4 sGG )NN) __name__ __module__ __qualname____doc__r<propertyr;rTrDr#r!r5r5bs)B (( @,;r#r5ceZdZdZdZdZy)IPythonPTLexerz3 Wrapper around PythonLexer and BashLexer. c t}t|j|_t|j|_t|j t|j t|jt|jt|jt|jt|jd|_ y)N)HTMLhtml javascriptjsperlrubylatex) pygments_lexersr Python3Lexer python_lexer BashLexer shell_lexer HtmlLexerJavascriptLexer PerlLexer RubyLexerTexLexer magic_lexers)r:ls r!r<zIPythonPTLexer.__init__s )!..9(5"!++.!!++.'(9(9: 1 12!!++.!!++."1::. r#cd|jj}|j}|jds|jdr |j}nK|jdr:|j j D]\}}|jd|zs|}n|j|S)N!z%%bashz%%)r0lstripr}r'rritems lex_document)r:rLr0lexermagicrs r!rzIPythonPTLexer.lex_documents}}##%!! ??3 4??8#<$$E __T " --335 q??4%<0E  !!(++r#N)rkrlrmrnr<rrpr#r!rrrrs  ,r#rr)!rnr_rIPython.core.completerrrrprompt_toolkit.completionrrprompt_toolkit.lexersr r prompt_toolkit.patch_stdoutr IPython.core.getipythonr pygments.lexerslexersr{rrFrHobject_completion_sentinelstrr"intr)r,r3r5rrrpr#r!rs<'/4/* x##s#L  S   $3$s$#$``F!,U!,r#