U C^Y@sdddlmZmZddlZddlmZmZmZes4dndZes@dndZ esLd nd Z Gd d d e Z dS) )unicode_literalsprint_functionN)color supports_ansiNO_UTF8u└─z|_u├─z|__u──__c@sHeZdZdddddeddfdd Zd d Zd d ZddZddZdS)TracebackPrinterZredZblueZyellowNc Cst||_||_||_d||_|dkr:dttjj}n|dk rLd|}||_ t ||_ ||_ ||_ t|_dS)amInitialize a traceback printer. color_error (unicode / int): Color name or code for errors. color_tb (unicode / int): Color name or code for traceback headline. color_highlight (unicode / int): Color name or code for highlights. indent (int): Indentation in spaces. tb_base (unicode): Name of directory to use to show relative paths. For example, "thinc" will look for the last occurence of "/thinc/" in a path and only show path to the right of it. tb_exclude (tuple): List of filenames to exclude from traceback. tb_range_start (int): The starting index from a traceback to include. tb_range_end (int): The final index from a traceback to include. If None the traceback will continue until the last record. RETURNS (TracebackPrinter): The traceback printer.  .z{}{}Nz/{}/) color_errorcolor_tbcolor_highlightindentformatosgetcwdpathseptb_basetuple tb_excludetb_range_start tb_range_endr) selfrrrrrrrrr4/tmp/pip-install-6_kvzl1k/wasabi/wasabi/traceback.py__init__ s   zTracebackPrinter.__init__cs||dd}|dd}jr.t|jdd}|rNddfdd |Dnd }|rb||nd }d j|||}|S) aOutput custom formatted tracebacks and errors. title (unicode): The message title. *texts (unicode): The texts to print (one per line). highlight (unicode): Optional sequence to highlight in the traceback, e.g. the bad value that caused the error. tb (iterable): The traceback, e.g. generated by traceback.extract_stack(). RETURNS (unicode): The formatted traceback. Can be printed or raised by custom exception. highlightFtbNTfgbold csg|]}j|qSr)r).0textrrr Dsz-TracebackPrinter.__call__..z {}{}{}{} )getrrrjoin_get_tracebackrr)rtitleZtextssettingsr!r"infomsgrr)r__call__5s  $zTracebackPrinter.__call__csfdd|D}jdk r,|jjn |jdfddtD}d|}d}jr|t|jdd}dj||j d S) Ncs g|]}|djs|qS)r)endswithr)r'recordr)rrr*Ksz3TracebackPrinter._get_traceback..c s2g|]*\}\}}}}|||||tqSr)_format_tracebacklen)r'irlinefnr(r!rZtb_rangerrr*Qsr&z Traceback:Tr#z {indent}{title} {indent}{tb})r/r"r) rr enumerater-striprrrrr)rr"r!Ztb_listZtb_datar/rr;rr.Is" zTracebackPrinter._get_tracebackc Csd}||dkrtntt|} |jrB|j|krB||jdd}||dkr\||||nd}|jr~t|dd}t|dd}|j|j || |||dS)Nz1{base_indent}{indent} {fn} in {path}:{line}{text}rr+T)r%)Z underline)Z base_indentr9rr(r:r) LINE_EDGE LINE_FORK LINE_PATHrrsplit_format_user_errorrrrr) rrr9r:r(r8countr!templaterrrrr6]s   z"TracebackPrinter._format_tracebackcCsTd|d}|jr t||jd}|rD|jrDt||jd}|||}d|j||S)Nz z >>>)r$z {} {} {})rrrrreplacerr)rr(r8r!spacingZformatted_highlightrrrrBos   z#TracebackPrinter._format_user_error) __name__ __module__ __qualname__rr r3r.r6rBrrrrr s (r ) __future__rrrutilrrrr>r?r@objectr rrrrs