B e]@s\ddlmZmZddlmZmZmZes,dndZes8dndZesDdnd Z Gd d d e Z d S) )unicode_literalsprint_function)color supports_ansiNO_UTF8u└─z|_u├─z|__u──__c@sDeZdZdddddefddZdd Zd d Zd d ZddZdS)TracebackPrinterZredZblueZyellowNcCsF||_||_||_d||_|r*d|nd|_t||_t|_dS)aInitialize 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. RETURNS (TracebackPrinter): The traceback printer.  z/{}/N) color_errorcolor_tbcolor_highlightindentformattb_basetuple tb_excluder)selfr r rrrrr4/tmp/pip-install-b8evvk6i/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. highlightFtbNT)fgbold csg|]}j|qSr)r).0text)rrr 9sz-TracebackPrinter.__call__..z {}{}{}{} )getrrr join_get_tracebackrr)rtitleZtextssettingsrrinfomsgr)rr__call__*s  $zTracebackPrinter.__call__csrfdd|D}|ddfddtD}d|}d}jr`t|jdd }d j||jd S) Ncs g|]}|djs|qS)r)endswithr)rrecord)rrrr@sz3TracebackPrinter._get_traceback..c s2g|]*\}\}}}}|||||tqSr)_format_tracebacklen)ripathlinefnr)rrtb_rangerrrCsrz Traceback:T)rrz {indent}{title} {indent}{tb})r$rr) enumerater"striprrr rr)rrrZtb_listZtb_datar$r)rrr3rr#>s  zTracebackPrinter._get_tracebackc Csd}||dkrtntt|} |jrB|j|krB||jdd}||dkr\||||nd}|jr~t|dd}t|dd}|j|j || |||dS)Nz3{base_indent}{indent} {fn} [{line}] in {path}{text}rr T)r)Z underline)Z base_indentr1rrr2r0) LINE_EDGE LINE_FORK LINE_PATHrrsplit_format_user_errorrrrr) rr0r1r2rr/countrtemplaterrrrr-Ns  z"TracebackPrinter._format_tracebackcCsTd|d}|jr t||jd}|rD|jrDt||jd}|||}d|j||S)Nz z >>>)rz {} {} {})rrr rreplacerr)rrr/rspacingZformatted_highlightrrrr:`s   z#TracebackPrinter._format_user_error) __name__ __module__ __qualname__rrr(r#r-r:rrrrr sr N) __future__rrutilrrrr6r7r8objectr rrrrs