ZL i] dZddlZddlZddlZddlmZmZddlmZm Z ddl m Z e dddee d e d ed dfd Ze dddee d e d ed dfd Ze dddee d e d ed dfdZddee d e d ed dfdZde de de de d e f dZej&dZde d ee fdZde de de de d e f dZde d e fdZe dddde de d e fdZy) zMNice output for Black. The double calls are for patching purposes in tests. N)AnyOptional)echostyle) mypyc_attrT) patchablemessagenlstylesreturnc N|d|vrd|d<t|fi|}t||dy)NboldTr errrrr r r s R/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/black/output.py_outrs4  !F6N*6*RT"c N|d|vrd|d<t|fi|}t||dy)NfgredTrrrs r_errrs4 v  F4L*6*RT"rc t|fd|i|yNr )rrs routr!s"R"6"rc t|fd|i|yr)rrs rrr&s"R"6"raba_nameb_namec ltj|}tj|}t|dDcgc][\}}|ddk(rNtdj |d|ddzdj |d|ddz|d||d|]}}}dj |Scc}}w)zHReturn a unified diff string between each cell in notebooks `a` and `b`.cells cell_typecodesource z:cell_)jsonloads enumeratediffjoin) rrr r!a_nbb_nb cell_numbercell diff_liness r ipynb_diffr3*s ::a=D ::a=D"+4=!9  K   & GGDM+.x8 9D @ GGDM+.x8 9D @hf[M *hf[M *   J  77:  sA B0z(.*?(?:\r\n|\n|\r|$))r'ctj|Dcgc]}|d }}|ddk(r|jd|Scc}w)zSplit a string into lines ignoring form feed and other chars. This mimics how the Python parser splits source code. A simplified version of the function with the same name in Lib/ast.py rr&) _line_patternfinditerpop)r'matchresults r_splitlines_no_ffr;>sH%2$:$:6$B C5eAh CF C bzR 2 MDs Acddl}t|}t|}g}|j||||dD]A}|ddk(r|j||j|dz|jdCdj |S) z9Return a unified diff string between strings `a` and `b`.rN)fromfiletofilenr5r(z\ No newline at end of file r&)difflibr; unified_diffappendr-) rrr r!rAa_linesb_linesr2lines rr,r,Ks"G"GJ$$6&A% @ 8t    d #   dTk *   > ? @ 77: rcontentscf|jd}t|D]\}}|jds|jdr d|zdz}nM|jdr d|zdz}n3|jdr d |zdz}n|jd rd |zdz}|||<dj|S) z(Inject the ANSI color codes to the diff.r(z+++z---zzz@@z+z-z)splitr+ startswithr-)rGlinesirFs r color_diffrO`s NN4 EU# 4 ??5 !T__U%;t#i/D __T "$y0D __S !$y0D __S !$y0Da  99U r)ensure_final_newlineoutputrPctjddddd5}|D]3}|j||s|s|ddk7s#|jd5 d d d |jS#1swYjSxYw) z;Dump `output` to a temporary file. Return path to the file.wblk_z.logFutf8)modeprefixsuffixdeleteencodingr5r(N)tempfileNamedTemporaryFilewritename)rPrQfrMs r dump_to_filer`ps{  $ $ uv   E GGEN#%)t2C   66M 66MsA)A)A)A))A=)NT)__doc__r)rer[typingrrclickrrmypy_extensionsrstrboolrrrrr3compiler6listr;r,rOr`rrrks   & d#(3-#D#3#4## d#(3-#D#3#4## d###4###$#####4###$###sCC" 34  c d3i CCcc*     d<@ # T S  r