f JddlZddlZddlmZddlmZddlmZddlm Z ddlm Z ejrddl m Z dd ejed efd Zd ed ejededed ef dZdej(eej*fd ej,eej*ffdZy)N)CodeType) TracebackType)TemplateSyntaxError) internal_code)missing)Contextsourcereturnc@tj\}}}tjt|}tjt |}t |trR|jsFd|_||_ |jdt|d|jxsd|j}n |j}g}||jj t"vr |j}+|jj$j'd}|E|j)|j*}t|||j|}|j-|n|j-||j}|d}t/|D] }||_|} |j|S)axRewrite the current exception to replace any tracebacks from within compiled template code with tracebacks that look like they came from the template source. This must be called within an ``except`` block. :param source: For ``TemplateSyntaxError``, the original source if known. :return: The original exception with the rewritten traceback. TNz __jinja_template__)sysexc_infotcast BaseExceptionr isinstancer translatedr with_tracebackfake_tracebackfilenamelinenotb_nexttb_framef_coder f_globalsgetget_corresponding_lineno tb_linenoappendreversed) r _ exc_valuetbstacktemplaterfake_tbrs U/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/jinja2/debug.pyrewrite_traceback_stackr)so||~Ay"}i0I  r "B)01):N:N# !    & tY//>; @P@P  ZZ E . ;;   .B ;;((,,-AB  66r||DF$YH4E4EvNG LL ! LL  ZZ! .$Guo   # #G ,,r#r$rrcD|2t|jj}|jddni}|||d}t d|dz zdz|d}d}|A|jj j }|d k(rd }n|jd rd |d d}tjdk\r|j|}nt|j|j|j|j|j |j"|j$|j&|j(|j*||j,|j.|j0|j2} t5|||y#t6$r$tj8dj:cYSwxYw)a,Produce a new traceback object that looks like it came from the template source instead of the compiled code. The filename, line number, and location name will point to the template, and the local variables will be the current template context. :param exc_value: The original exception to be re-raised to create the new traceback. :param tb: The original traceback to get the local variables and code info from. :param filename: The template filename. :param lineno: The line number in the template source. N__jinja_exception__)__name____file__r, rzraise __jinja_exception__execr&rootztop-level template codeblock_zblock ))co_name)get_template_localsrf_localspopcompilerr6 startswithr version_inforeplacer co_argcountco_kwonlyargcount co_nlocals co_stacksizeco_flagsco_code co_constsco_names co_varnames co_filenameco_firstlineno co_lnotab co_freevars co_cellvarsr0rrr) r#r$rrlocalsglobalscodelocationfunctions r(rrLs ~%R[[%9%9: ($/(G   998VD H ~;;%%-- v 0H   * /0H 6!||H|-     " " OO    MM LL NN MM           NN       () T7F# )||~a ((()s$ E22*FF real_localsc|jd}||jj}ni}i}|jD]c\}}|j dr|t ur |j dd\}}}t|}|j|dd} | |ks]||f||<e|jD](\}\}}|t ur|j|d$|||<*|S#t$rYwxYw)zlBased on the runtime locals, get the context that would be available at that point in the template. contextNl_r"r7)r) rget_allcopyitemsr<rsplitint ValueErrorr:) rRctxdatalocal_overridesnamevaluer" depth_strdepth cur_depths r(r8r8s "-!;C #&;;=#5#5#7 9;O"((* et$(8  !%C!3 Ay$ NE$''e4Q7 u %*ENOD !+",113jq% G  HHT4 DJ 4 K   s(!C** C65C6)N)rtypingrtypesrr exceptionsrutilsrr TYPE_CHECKINGruntimer Optionalstrrr)r[rMappingAnyDictr8r*r(rqs + ?? ;-AJJsO;-};-|G)G)"#**]";G)GJG)TWG)G)T)QYYsAEEz%:)qvvc155j?Q)r*