PL i0(dZddlZddlZddlmZddlmZGddeZGddeZd Z Gd d eZ Gd d eZ GddeZ GddeZ GddeZGddeZGddZddZdZdZdZedZy)zexception classesN)compat)utilc eZdZy) MakoExceptionN__name__ __module__ __qualname__U/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/mako/exceptions.pyrrr rc eZdZy)RuntimeExceptionNrr r r rrrr rc$|d||fzSd|||fzS)Nz at line: %d char: %dz" in file '%s' at line: %d char: %dr )linenoposfilenames r _format_fileposrs)&&#663x6MMMr ceZdZdZy)CompileExceptionc tj||t|||z||_||_||_||_yNr__init__rrrrsourceselfmessagerrrrs r rzCompileException.__init__ A 'OFCBB     r Nrr r rr r r rrr rceZdZdZy)SyntaxExceptionc tj||t|||z||_||_||_||_yrrrs r rzSyntaxException.__init__+r r Nr!r r r r$r$*r"r r$ceZdZdZy)UnsupportedErrorz&raised when a retired feature is used.Nrr r __doc__r r r r'r'5s0r r'ceZdZdZy)NameConflictErrorz3raised when a reserved word is used inappropriatelyNr(r r r r+r+:s=r r+c eZdZy)TemplateLookupExceptionNrr r r r-r-?rr r-c eZdZy)TopLevelLookupExceptionNrr r r r/r/Crr r/cjeZdZdZd dZedZdZdZedZ edZ ed Z d Z y) RichTracebackzPull the current exception from the ``sys`` traceback and extracts Mako-specific template information. See the usage examples in :ref:`handling_exceptions`. Ncd\|_|_||tj\}}}|xs}|}||_|j ||_t|jttfr=|jj|_|jj|_d|_ |jy)N)rT) rrsysexc_infoerror_initrecords isinstancerr$ _has_source _init_message)rr6 tracebacktvaluetbacks r rzRichTraceback.__init__Ps#(  T[ =I-!llnOAue =JQE  I zz), djj#3_"E F**++DK**++DK#D  r c@tj|jSr)rexception_namer6rs r errornamezRichTraceback.errornamefs$$TZZ00r cX t|j|_t |jtst|jdd|_yy#t$rL t|j|_n-#t$r!|jj d|_YnwxYwYwxYw)z+Find a unicode representation of self.errorrasciireplaceN)strr6r UnicodeErrorUnicodeEncodeErrorargsr9rBs r r;zRichTraceback._init_messagejs 2tzz?DL$,,,t||Wi@DL- 2 2"4:: % 2 $zzq1  2 2s5A B)A98B)9'B# B)"B##B)(B)c#nK|D],}|d|d|d|d|dft|dd.yw)Nr)tuple)rr8recs r _get_reformatted_recordsz&RichTraceback._get_reformatted_recordsxsN &C1v!1vs1vs1vs1v66C!Ho%  &s35cJt|j|jS)zReturn a list of 4-tuple traceback records (i.e. normal python format) with template-corresponding lines remapped to the originating template. )listrRr8rBs r r<zRichTraceback.tracebacksD11$,,?@@r c,t|jSr)reversedr8rBs r reverse_recordszRichTraceback.reverse_recordss %%r cJt|j|jS)z;Return the same data as traceback, except in reverse order.)rTrRrWrBs r reverse_tracebackzRichTraceback.reverse_tracebacks D11$2F2FGHHr c ddl}i}tj|}g}|D]O\}}}} | sd} ||\} } } | |dz }|t| kr | |dz }nd}|j|||| | ||fQ|jstt|dz dd D]'}||d s ||d |_||d |_|S|r t#|d dd 5}t%j&|}|sd }|j)d|j+|_dddr |jj-||_|d d|_|S#t$r |jj |} | j }| j}| jxs| jxs|} n*#t$r|j|||| ddddfYYwxYwd}|jj}|j|d}|d} |jdDcgc]}|ncc}w} }| | | f||<YwxYw#1swY$xYw#t.$r d|_YwxYw)aformat a traceback from sys.exc_info() into 7-item tuples, containing the regular four traceback tuple items, plus the original template filename, the line number adjusted relative to the template source, and code line from that line number of the template.rNr3T) full_line_mapr\ rNrbzutf-8) mako.templater< extract_tbKeyErrortemplate_get_module_infocodertemplate_filename template_uriappend ModuleInfoget_module_source_metadatasplitlenrangeropenrparse_encodingseekreaddecodeIOError)rtrcbackmakomods rawrecords new_trcbackrrfunctionlineline_maptemplate_linesrginfo module_sourcetemplate_source template_lnmtm source_mapline_ template_linelfpencodings r r7zRichTraceback._inits ))'2  0:;  ,Hfh% O@DX=>+!$"-a."3DK"-a."3DK ) 5  )!+b/!"4d;4r'+':':2'>H#++2GGAJ*,'')DK 4 $*.++*<* <%! from mako.exceptions import RichTraceback %>\ <% tback = RichTraceback(error=error, traceback=traceback) %>\ Traceback (most recent call last): % for (filename, lineno, function, line) in tback.traceback: File "${filename}", line ${lineno}, in ${function or '?'} ${line | trim} % endfor ${tback.errorname}: ${tback.message} )rardTemplate)lookuprvs r text_error_templaters# == ! !  r cddlmaddlmay)Nr)syntax_highlight)pygments_html_formatter)mako.ext.pygmentpluginrrr r r _install_pygmentsr s7>r c"ddlmdadfd ay)Nr html_escapecSrr )rlanguagers r rrs r )r3N) mako.filtersrrrrs@r _install_fallbackrs("r cL ty#t$r tYywxYwr)r ImportErrorrr r r _install_highlightingrs" s ##cjddl}|jjdtjdS)aProvides a template that renders a stack trace in an HTML format, providing an excerpt of code as well as substituting source template filenames, line numbers and code for that of the originating source template, as applicable. The template's default ``encoding_errors`` value is ``'htmlentityreplace'``. The template has two options. With the ``full`` option disabled, only a section of an HTML document is returned. With the ``css`` option disabled, the default stylesheet won't be included. rNa <%! from mako.exceptions import RichTraceback, syntax_highlight,\ pygments_html_formatter %> <%page args="full=True, css=True, error=None, traceback=None"/> % if full: Mako Runtime Error % endif % if css: % endif % if full: % endif

Error !

<% tback = RichTraceback(error=error, traceback=traceback) src = tback.source line = tback.lineno if src: lines = src.split('\n') else: lines = None %>

${tback.errorname}: ${tback.message|h}

% if lines:
% for index in range(max(0, line-4),min(len(lines), line+5)): <% if pygments_html_formatter: pygments_html_formatter.linenostart = index + 1 %> % if index + 1 == line: <% if pygments_html_formatter: old_cssclass = pygments_html_formatter.cssclass pygments_html_formatter.cssclass = 'error ' + old_cssclass %> ${lines[index] | syntax_highlight(language='mako')} <% if pygments_html_formatter: pygments_html_formatter.cssclass = old_cssclass %> % else: ${lines[index] | syntax_highlight(language='mako')} % endif % endfor
% endif
% for (filename, lineno, function, line) in tback.reverse_traceback:
${filename}, line ${lineno}:
<% if pygments_html_formatter: pygments_html_formatter.linenostart = lineno %>
${line | syntax_highlight(filename)}
% endfor
% if full: % endif htmlentityreplace)output_encodingencoding_errors)rardrr4getdefaultencoding)rvs r html_error_templater's> == ! !g P..0+U "k kr r)r)r4r<rvrr Exceptionrrrrr$r'r+r-r/r1rrrrrr r r rs  I  } N}m1}1 > >  m  5 ggT8? zr