관리-도구
편집 파일: utils.cpython-37.pyc
B ��Yh � @ sB d Z ddlmZ ddlZddlmZ dd� Zddd�Zd d � ZdS )z� raven.contrib.django.utils ~~~~~~~~~~~~~~~~~~~~~~~~~~ :copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. � )�absolute_importN)�settingsc c sJ dV | � d�}x&|dkr6|d V | � d|d �}qW t| �d V d S )Nr � � )�find�len)�template_source�p� r �K/opt/alt/python37/lib/python3.7/site-packages/raven/contrib/django/utils.py�linebreak_iter s r c C s� dd� }|d k rn|d }|d }g }|dg|d d d 7 }x|d D ]\}}|� |� qHW |dgd 7 }n�| r�| \}\} } t|d d � }}|�� }d }d} g }xBtt|��D ]2\}}| | kr�| |kr�|}|� || |� � |} q�W |r�|d kr�i S ntd ��|d k�rd}d}n|�d�d }||t|d d�|� �}|||d |d � �}||| g�d }tj � |�|||||d�|d�S )Nc S sB g }x8| D ]0}t |ttf�r0t|�dkr0|d }|�|� q W |S )N� r )� isinstance�list�tupler �append)�items�rv�itemr r r �_remove_numbers s z/get_data_from_template.<locals>._remove_numbers�line�name� �source_linesr � ZloadnamezSource or debug neededz<unknown filename>z/templates/���� r )�filenameZabs_path�pre_context�context_line�lineno�post_context)�template�culprit)r �getattr�reload� enumerater � TypeError�split�max�os�path�basename)�source�debugr r r r �numr �origin�start�endr# r Zupto�nextr r! r r r r �get_data_from_template sL r4 c C sn t jrd| jkr| jd }nNd| jkr2| jd }n8| jd }t| jd �}|| �� rXdpZdkrjd||f }|S )z] A reimplementation of Django's get_host, without the SuspiciousOperation check. ZHTTP_X_FORWARDED_HOSTZ HTTP_HOSTZSERVER_NAMEZSERVER_PORTZ443Z80z%s:%s)r ZUSE_X_FORWARDED_HOSTZMETA�strZ is_secure)Zrequest�hostZserver_portr r r �get_hostT s r7 )N) �__doc__� __future__r r* Zdjango.confr r r4 r7 r r r r �<module> s <