관리-도구
편집 파일: templates.cpython-38.pyc
U �Mg] � @ s� d dl Z d dlmZ d dlmZ d dlmZ d dlZd dl m Z d dlmZ d dl mZ er�d dl mZ d d l mZ d d l mZ d dl mZ d dl mZ zd d lmZ W n ek r� d dlmZ Y nX dd� Zdd� Zdd� Zdd� Zdd� Zdd� ZdS )� N)�TemplateSyntaxError)� mark_safe)�VERSION)�OP)�ensure_integration_enabled)� TYPE_CHECKING)�Any)�Dict)�Optional)�Iterator)�Tuple)�Origin)�LoaderOriginc C sj t | d�rt| j�S t | d�r(t| j�S t| t�rft | d�rf| j}t|tt f�rft|d t �rft|�S d S )N�template_debug�django_template_source�sourcer )�hasattr�_get_template_frame_from_debugr �_get_template_frame_from_sourcer � isinstancer r �tuple�listr )� exc_valuer � r �V/opt/hc_python/lib/python3.8/site-packages/sentry_sdk/integrations/django/templates.py�!get_template_frame_from_exception s �r c C s* t | ttf�r"| r&d�| d �S n| S d S )Nz [{}, ...]r )r r r �format)� template_namer r r �_get_template_name_description3 s r c s� ddl m} ddlm� | j�tt� �j�� �fdd���}|| _tdk rNd S dd l }|j j�t� ��t� ��d � �fdd� ��}||j _d S ) Nr )�SimpleTemplateResponse)�DjangoIntegrationc sJ t jtjt| j�� jd��&}|�d| j� �� | �W 5 Q R � S Q R X d S )N��op�name�origin�context) � sentry_sdk� start_spanr �TEMPLATE_RENDERr r r$ �set_dataZcontext_data�fget)�self�span)r �real_rendered_contentr r �rendered_contentC s �z)patch_templates.<locals>.rendered_content)� � c st |pi }d|kr$t t�� �� �|d<